mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-24 04:18:03 +00:00
mappings: add new keymap option
This commit is contained in:
parent
6670d752c7
commit
aff88b8379
1 changed files with 39 additions and 26 deletions
|
@ -31,6 +31,12 @@
|
||||||
options =
|
options =
|
||||||
mapConfigOptions
|
mapConfigOptions
|
||||||
// {
|
// {
|
||||||
|
key = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = ''
|
||||||
|
Key that triggers this keybind.
|
||||||
|
'';
|
||||||
|
};
|
||||||
mode = mkOption {
|
mode = mkOption {
|
||||||
type = either str (listOf str);
|
type = either str (listOf str);
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -38,27 +44,47 @@
|
||||||
|
|
||||||
See `:help map-modes` for a list of modes.
|
See `:help map-modes` for a list of modes.
|
||||||
'';
|
'';
|
||||||
|
example = ''"nvc" for normal, visual and command mode'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# legacy stuff
|
# legacy stuff
|
||||||
mapOption = submodule {
|
legacyMapOption = submodule {
|
||||||
options = mapConfigOptions;
|
options = mapConfigOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
mapOptions = mode:
|
mapOptions = mode:
|
||||||
mkOption {
|
mkOption {
|
||||||
description = "Mappings for ${mode} mode";
|
description = "Mappings for ${mode} mode";
|
||||||
type = attrsOf mapOption;
|
type = attrsOf legacyMapOption;
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
maps = mkOption {
|
keymaps = mkOption {
|
||||||
type = submodule {
|
type = listOf mapType;
|
||||||
freeformType = attrsOf mapType;
|
description = "Custom keybindings.";
|
||||||
options = {
|
example = ''
|
||||||
|
vim.keymaps = [
|
||||||
|
{
|
||||||
|
key = "<leader>m";
|
||||||
|
mode = "n";
|
||||||
|
silent = true;
|
||||||
|
action = ":make<CR>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "<leader>l";
|
||||||
|
mode = ["n" "x"];
|
||||||
|
silent = true;
|
||||||
|
action = "<cmd>cnext<CR>";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
'';
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
maps = {
|
||||||
normal = mapOptions "normal";
|
normal = mapOptions "normal";
|
||||||
insert = mapOptions "insert";
|
insert = mapOptions "insert";
|
||||||
select = mapOptions "select";
|
select = mapOptions "select";
|
||||||
|
@ -73,17 +99,4 @@ in {
|
||||||
command = mapOptions "command-line";
|
command = mapOptions "command-line";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
default = {};
|
|
||||||
description = "Custom keybindings.";
|
|
||||||
example = ''
|
|
||||||
maps = {
|
|
||||||
"<leader>m" = {
|
|
||||||
mode = "n";
|
|
||||||
silent = true;
|
|
||||||
action = "<cmd>make<CR>";
|
|
||||||
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
|
||||||
};
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue