Compare commits

..

1 commit

Author SHA1 Message Date
Ching Pei Yang
74496972c4
Merge 593435318d into 773186d93d 2024-08-02 10:56:08 +00:00
3 changed files with 17 additions and 30 deletions

View file

@ -57,6 +57,13 @@
};
lznKeysSpec = submodule {
apply = x:
x
// {
"@1" = x.lhs;
"@2" = x.rhs;
};
options = {
desc = mkOption {
description = "Description of the key map";
@ -102,7 +109,7 @@
mode = mkOption {
description = "Modes to bind in";
type = listOf str;
default = ["n" "x" "s" "o"];
default = ["n"];
};
};
};
@ -186,7 +193,7 @@
keys = mkOption {
description = "Lazy-load on key mapping";
default = null;
type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]); # TODO: support lz.n.KeysSpec
type = nullOr (oneOf [str (listOf str) lznKeysSpec]); # TODO: support lz.n.KeysSpec
};
# TODO: enabled, beforeAll, colorscheme, priority, load

View file

@ -13,13 +13,16 @@
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";
};
@ -31,13 +34,6 @@ 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<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)
];
};
};
};

View file

@ -12,23 +12,8 @@
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" "keys"])
(removeAttrs spec ["package" "setupModule" "setupOpts"])
// {
"@1" = name;
after = mkLuaInline ''
@ -40,7 +25,6 @@
${optionalString (spec.after != null) spec.after}
end
'';
keys = map toLuzLznKeySpec spec.keys;
};
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
in {