mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/which-key: remove which-key logic from keymap module
This commit is contained in:
parent
dd6a114e52
commit
05b77732e3
3 changed files with 31 additions and 31 deletions
|
@ -280,32 +280,15 @@ in {
|
||||||
(config.keymaps ++ modeMapsAsList);
|
(config.keymaps ++ modeMapsAsList);
|
||||||
in
|
in
|
||||||
optionalString (mappings != [])
|
optionalString (mappings != [])
|
||||||
(
|
''
|
||||||
if config.plugins.which-key.enable
|
-- Set up keybinds {{{
|
||||||
then ''
|
do
|
||||||
-- Set up keybinds {{{
|
local __nixvim_binds = ${helpers.toLuaObject mappings}
|
||||||
do
|
for i, map in ipairs(__nixvim_binds) do
|
||||||
local __nixvim_binds = ${helpers.toLuaObject mappings}
|
vim.keymap.set(map.mode, map.key, map.action, map.options)
|
||||||
for i, map in ipairs(__nixvim_binds) do
|
|
||||||
if not map.action then
|
|
||||||
require("which-key").register({[map.key] = {name = map.options.desc }})
|
|
||||||
else
|
|
||||||
vim.keymap.set(map.mode, map.key, map.action, map.options)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
-- }}}
|
end
|
||||||
''
|
-- }}}
|
||||||
else ''
|
'';
|
||||||
-- Set up keybinds {{{
|
|
||||||
do
|
|
||||||
local __nixvim_binds = ${helpers.toLuaObject mappings}
|
|
||||||
for i, map in ipairs(__nixvim_binds) do
|
|
||||||
vim.keymap.set(map.mode, map.key, map.action, map.options)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- }}}
|
|
||||||
''
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,15 @@ in {
|
||||||
|
|
||||||
package = helpers.mkPackageOption "whick-key-nvim" pkgs.vimPlugins.which-key-nvim;
|
package = helpers.mkPackageOption "whick-key-nvim" pkgs.vimPlugins.which-key-nvim;
|
||||||
|
|
||||||
|
registrations = mkOption {
|
||||||
|
type = with types; attrsOf str;
|
||||||
|
default = {};
|
||||||
|
description = "Manually register the description of mappings.";
|
||||||
|
example = {
|
||||||
|
"<leader>p" = "Find git files with telescope";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
plugins = {
|
plugins = {
|
||||||
marks = helpers.defaultNullOpts.mkBool true "shows a list of your marks on ' and `";
|
marks = helpers.defaultNullOpts.mkBool true "shows a list of your marks on ' and `";
|
||||||
|
|
||||||
|
@ -194,8 +203,14 @@ in {
|
||||||
mkIf cfg.enable {
|
mkIf cfg.enable {
|
||||||
extraPlugins = [cfg.package];
|
extraPlugins = [cfg.package];
|
||||||
|
|
||||||
extraConfigLua = ''
|
extraConfigLua =
|
||||||
require("which-key").setup(${helpers.toLuaObject setupOptions})
|
''
|
||||||
'';
|
require("which-key").setup(${helpers.toLuaObject setupOptions})
|
||||||
|
''
|
||||||
|
+ (
|
||||||
|
optionalString (cfg.registrations != {}) ''
|
||||||
|
require("which-key").register(${helpers.toLuaObject cfg.registrations})
|
||||||
|
''
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
defaults = {
|
defaults = {
|
||||||
plugins.which-key = {
|
plugins.which-key = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
# Simple mapping with only Description
|
||||||
|
registrations."ff" = "Test";
|
||||||
|
|
||||||
plugins = {
|
plugins = {
|
||||||
marks = true;
|
marks = true;
|
||||||
registers = true;
|
registers = true;
|
||||||
|
@ -86,7 +90,5 @@
|
||||||
filetypes = [];
|
filetypes = [];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
# Simple mapping with only Description
|
|
||||||
maps.byMode.normal."ff".options.desc = "Test";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue