Hyprland-dotfiles/nvim/lua/modules/configs/tool/toggleterm.lua
2024-07-21 02:51:17 -04:00

52 lines
1.7 KiB
Lua

return function()
require("modules.utils").load_plugin("toggleterm", {
-- size can be a number or function which is passed the current terminal
size = function(term)
if term.direction == "horizontal" then
return vim.o.lines * 0.30
elseif term.direction == "vertical" then
return vim.o.columns * 0.40
end
end,
on_open = function(term)
-- Prevent infinite calls from freezing neovim.
-- Only set these options specific to this terminal buffer.
vim.api.nvim_set_option_value("foldmethod", "manual", { scope = "local" })
vim.api.nvim_set_option_value("foldexpr", "0", { scope = "local" })
-- Prevent horizontal terminal from obscuring `nvim-tree`.
local api = require("nvim-tree.api")
local tree = require("nvim-tree.view")
if tree.is_visible() and term.direction == "horizontal" then
local width = vim.fn.winwidth(tree.get_winnr())
api.tree.toggle()
tree.View.width = width
api.tree.toggle(false, true)
end
end,
highlights = {
Normal = {
link = "Normal",
},
NormalFloat = {
link = "NormalFloat",
},
FloatBorder = {
link = "FloatBorder",
},
},
open_mapping = false, -- [[<c-\>]],
hide_numbers = true, -- hide the number column in toggleterm buffers
shade_filetypes = {},
shade_terminals = false,
shading_factor = "1", -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
start_in_insert = true,
persist_mode = false,
insert_mappings = true, -- whether or not the open mapping applies in insert mode
persist_size = true,
direction = "horizontal",
close_on_exit = true, -- close the terminal window when the process exits
shell = vim.o.shell, -- change the default shell
})
end