diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index c993f1d..7fa7448 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -57,13 +57,6 @@ }; lznKeysSpec = submodule { - apply = x: - x - // { - "@1" = x.lhs; - "@2" = x.rhs; - }; - options = { desc = mkOption { description = "Description of the key map"; diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index f1e75b5..1416461 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -13,16 +13,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 +31,13 @@ in { setupModule = "nvim-tree"; inherit (cfg) setupOpts; cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"]; + + keys = [ + (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) + ]; }; }; }; diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index 5e25939..645dfb9 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -12,8 +12,23 @@ inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.lazy; + toLuzLznKeySpec = { + desc, + noremap, + expr, + nowait, + ft, + lhs, + rhs, + mode, + }: { + "@1" = lhs; + "@2" = rhs; + inherit desc noremap expr nowait ft mode; + }; + toLuaLznSpec = name: spec: - (removeAttrs spec ["package" "setupModule" "setupOpts"]) + (removeAttrs spec ["package" "setupModule" "setupOpts" "keys"]) // { "@1" = name; after = mkLuaInline '' @@ -25,6 +40,7 @@ ${optionalString (spec.after != null) spec.after} end ''; + keys = map toLuzLznKeySpec spec.keys; }; lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins; in {