From f29664626bd6f04a4fc0cd9089c6ba98b8b49cff Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 14:46:05 +0200 Subject: [PATCH] nvim-tree: move to lz.n keymaps --- modules/plugins/filetree/nvimtree/config.nix | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index f1e75b5..8ed3c62 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -4,6 +4,7 @@ pkgs, ... }: let + inherit (builtins) filter; inherit (lib.strings) optionalString; inherit (lib.modules) mkIf mkMerge; inherit (lib.nvim.binds) mkBinding; @@ -13,16 +14,13 @@ cfg = config.vim.filetree.nvimTree; self = import ./nvimtree.nix {inherit pkgs lib;}; + mkNormalBinding = lhs: rhs: desc: { + inherit lhs rhs desc; + mode = ["n"]; + }; inherit (self.options.vim.filetree.nvimTree) mappings; in { config = mkIf cfg.enable { - vim.maps.normal = mkMerge [ - (mkBinding cfg.mappings.toggle ":NvimTreeToggle" mappings.toggle.description) - (mkBinding cfg.mappings.refresh ":NvimTreeRefresh" mappings.refresh.description) - (mkBinding cfg.mappings.findFile ":NvimTreeFindFile" mappings.findFile.description) - (mkBinding cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) - ]; - vim.binds.whichKey.register = pushDownDefault { "t" = "+NvimTree"; }; @@ -34,6 +32,13 @@ in { setupModule = "nvim-tree"; inherit (cfg) setupOpts; cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"]; + + keys = filter ({lhs, ...}: lhs != null) [ + (mkNormalBinding cfg.mappings.toggle ":NvimTreeToggle" mappings.toggle.description) + (mkNormalBinding cfg.mappings.refresh ":NvimTreeRefresh" mappings.refresh.description) + (mkNormalBinding cfg.mappings.findFile ":NvimTreeFindFile" mappings.findFile.description) + (mkNormalBinding cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) + ]; }; }; };