From c6c04f0d1b3005c34db7e3540d70320f702e9928 Mon Sep 17 00:00:00 2001 From: n3oney Date: Wed, 3 May 2023 00:24:34 +0200 Subject: [PATCH] feat: add lazygit keybindings --- modules/terminal/toggleterm/config.nix | 6 ++---- modules/terminal/toggleterm/toggleterm.nix | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/terminal/toggleterm/config.nix b/modules/terminal/toggleterm/config.nix index 6e049a2..9caf691 100644 --- a/modules/terminal/toggleterm/config.nix +++ b/modules/terminal/toggleterm/config.nix @@ -6,7 +6,6 @@ with lib; with builtins; let cfg = config.vim.terminal.toggleterm; - toggleKey = ""; in { config = mkMerge [ ( @@ -14,7 +13,7 @@ in { vim.startPlugins = [ "toggleterm-nvim" ]; - + vim.maps.normal = mkBinding cfg.mappings.open "execute v:count . \"ToggleTerm\"" "Toggle terminal"; vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere '' @@ -57,11 +56,10 @@ in { hidden = true, on_open = function(term) vim.cmd("startinsert!") - vim.keymap.set( 't', [[${toggleKey}]], function() term:toggle() end, {silent = true, noremap = true, buffer = term.bufnr}) end }) - vim.keymap.set( 'n', [[gg]], function() lazygit:toggle() end, {silent = true, noremap = true}) + vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = 'Open lazygit [toggleterm]'}) ''; } ) diff --git a/modules/terminal/toggleterm/toggleterm.nix b/modules/terminal/toggleterm/toggleterm.nix index 347d579..35effff 100644 --- a/modules/terminal/toggleterm/toggleterm.nix +++ b/modules/terminal/toggleterm/toggleterm.nix @@ -37,6 +37,10 @@ with builtins; { default = pkgs.lazygit; description = "The package that should be used for lazygit. Setting it to null will attempt to use lazygit from your PATH"; }; + + mappings = { + open = mkMappingOption "Open lazygit [toggleterm]" "gg"; + }; }; }; }