From 8aaa3b34b54654dbc09715e774ad563014fe035f Mon Sep 17 00:00:00 2001 From: Nicolas Goudry Date: Tue, 11 Jun 2024 07:24:55 +0200 Subject: [PATCH] feat(plugins): add toggleterm --- plugins/toggleterm.nix | 77 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 plugins/toggleterm.nix diff --git a/plugins/toggleterm.nix b/plugins/toggleterm.nix new file mode 100644 index 0000000..3e4c19d --- /dev/null +++ b/plugins/toggleterm.nix @@ -0,0 +1,77 @@ +# homepage: https://github.com/akinsho/toggleterm.nvim +# nixvim doc: https://nix-community.github.io/nixvim/plugins/toggleterm/index.html +_: + +{ + opts = { + enable = true; + + settings = { + direction = "float"; + float_opts.border = "rounded"; + shading_factor = 2; + size = 10; + + highlights = { + Normal.link = "Normal"; + NormalNC.link = "NormalNC"; + NormalFloat.link = "NormalFloat"; + FloatBorder.link = "FloatBorder"; + StatusLine.link = "StatusLine"; + StatusLineNC.link = "StatusLineNC"; + WinBar.link = "WinBar"; + WinBarNC.link = "WinBarNC"; + }; + + # https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/toggleterm.lua#L66-L74 + on_create = '' + function(t) + vim.opt_local.foldcolumn = "0" + vim.opt_local.signcolumn = "no" + if t.hidden then + vim.keymap.set({ "n", "t", "i" }, "", function() t:toggle() end, { desc = "Toggle terminal", buffer = t.bufnr }) + end + end + ''; + }; + }; + + rootOpts.keymaps = [ + { + mode = "n"; + key = "tf"; + action = "ToggleTerm direction=float"; + options.desc = "Open floating terminal"; + } + { + mode = "n"; + key = "th"; + action = "ToggleTerm size=10 direction=horizontal"; + options.desc = "Open terminal in horizontal split"; + } + { + mode = "n"; + key = "tv"; + action = "ToggleTerm size=80 direction=vertical"; + options.desc = "Open terminal in vertical split"; + } + { + mode = "n"; + key = ""; + action = "execute v:count . 'ToggleTerm'"; + options.desc = "Toggle terminal"; + } + { + mode = "t"; + key = ""; + action = "ToggleTerm"; + options.desc = "Toggle terminal"; + } + { + mode = "i"; + key = ""; + action = "ToggleTerm"; + options.desc = "Toggle terminal"; + } + ]; +}