mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-22 08:53:28 +02:00
feat: register mapping with no actions in which-key when enabled
This commit is contained in:
parent
49f46d3b3d
commit
5fa54c6d39
2 changed files with 39 additions and 15 deletions
|
@ -105,10 +105,14 @@ with lib; let
|
||||||
options =
|
options =
|
||||||
mapConfigOptions
|
mapConfigOptions
|
||||||
// {
|
// {
|
||||||
action = mkOption {
|
action =
|
||||||
type = types.str;
|
if config.plugins.which-key.enable
|
||||||
description = "The action to execute.";
|
then helpers.mkNullOrOption types.str "The action to execute"
|
||||||
};
|
else
|
||||||
|
mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The action to execute.";
|
||||||
|
};
|
||||||
|
|
||||||
lua = mkOption {
|
lua = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
@ -180,16 +184,34 @@ in {
|
||||||
++ (genMaps "!" config.maps.insertCommand)
|
++ (genMaps "!" config.maps.insertCommand)
|
||||||
++ (genMaps "c" config.maps.command);
|
++ (genMaps "c" config.maps.command);
|
||||||
in {
|
in {
|
||||||
extraConfigLua = optionalString (mappings != []) ''
|
extraConfigLua =
|
||||||
-- Set up keybinds {{{
|
optionalString (mappings != [])
|
||||||
do
|
(
|
||||||
local __nixvim_binds = ${helpers.toLuaObject mappings}
|
if config.plugins.which-key.enable
|
||||||
|
then ''
|
||||||
for i, map in ipairs(__nixvim_binds) do
|
-- Set up keybinds {{{
|
||||||
vim.keymap.set(map.mode, map.key, map.action, map.config)
|
do
|
||||||
end
|
local __nixvim_binds = ${helpers.toLuaObject mappings}
|
||||||
end
|
for i, map in ipairs(__nixvim_binds) do
|
||||||
-- }}}
|
if not map.action then
|
||||||
'';
|
require("which-key").register({[map.key] = {name = map.config.desc }})
|
||||||
|
else
|
||||||
|
vim.keymap.set(map.mode, map.key, map.action, map.config)
|
||||||
|
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.config)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
''
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,5 +86,7 @@
|
||||||
filetypes = [];
|
filetypes = [];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
# Simple mapping with only Description
|
||||||
|
maps.normal."ff".desc = "Test";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue