nvim-tree: move to lz.n keymaps

This commit is contained in:
Ching Pei Yang 2024-08-03 14:46:05 +02:00
parent 085d5d304a
commit f29664626b

View file

@ -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<cr>" mappings.toggle.description)
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
];
vim.binds.whichKey.register = pushDownDefault {
"<leader>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<cr>" mappings.toggle.description)
(mkNormalBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
(mkNormalBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
(mkNormalBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
];
};
};
};