nixvim
nixvim copied to clipboard
Expose keymap options for all keymaps defined by nixvim
Nixvim defines keymaps for some plugins, we should expose all the possible options for those plugins (like desc, silent, ....) instead of only allowing to specify a key.
Available keymap options (2024-06-01)
- [x]
keymaps - [x]
keymapsOnEvents - [ ]
plugins.arrow.settings.mapping - [ ]
plugins.auto-save.keymaps.toggle - [ ]
plugins.barbar.keymaps - [ ]
plugins.chadtree.keymap.*.* - [ ]
plugins.codeium-vim.keymaps - [ ]
plugins.comment.settings.mappings - [ ]
plugins.cmp.*.mapping: currently raw lua passed directly tocmp.mapping. That function at least supportsmodesas a second parameter. - [ ]
plugins.copilot-lua.panel.keymap - [ ]
plugins.copilot-lua.suggestion.keymap - [ ]
plugins.coverage.keymaps - [ ]
plugins.diffview.keymaps - [ ]
plugins.floaterm.keymaps - [ ]
plugins.fzf-lua.keymaps - [ ]
plugins.gitignore.keymap - [ ]
plugins.harpoon.keymaps - [ ]
plugins.improved-search.keymaps(Done? Could be updated to usemkMapOptionSubmodulethough.) - [ ]
plugins.julia-cell.keymaps - [ ]
plugins.leap.specialKeys - [ ]
plugins.lsp.keymaps.diagnostic - [ ]
plugins.lsp.keymaps.lspBuf - [ ]
plugins.mkdnflow.mappings(uses a subset of the submodule already, can be ported tomkMapOptionSubmodulewithout breaking changes) - [ ]
plugins.multicursors.insertKeys - [ ]
plugins.multicursors.normalKeys - [ ]
plugins.multicursors.extendKeys - [ ]
plugins.neo-tree.window.mappingOptions - [ ]
plugins.neogen.keymaps - [ ]
plugins.nvim-osc52.keymaps(has aplugins.nvim-osc52.keymaps.enabletoggle!) - [ ]
plugins.obsidian.settings.mappings(uses a similar submodule tomkMapOptionSubmodule, but hasoptsinstead ofoptions) - [ ]
plugins.openscad.keymaps - [ ]
plugins.quickmath.keymap - [ ]
plugins.spider.keymaps - [ ]
plugins.startup.mappings - [ ]
plugins.telescope.keymaps(already uses a compatible subset of the keymap submodule) - [ ]
plugins.todo-comments.keymaps - [ ]
plugins.treesitter-refactor.navigation.keymaps - [ ]
plugins.treesitter-refactor.smartRename.keymaps - [ ]
plugins.typst-vim.keymaps - [ ]
plugins.vim-bbye.keymaps - [ ]
plugins.which-key.popupMappings - [ ]
plugins.wilder.<action>Key - [x]
plugins.wtf.keymaps.ai - [x]
plugins.wtf.keymaps.search
Related: https://github.com/nix-community/nixvim/blob/b3fb1c4c8189bc873911da3f31d18082a0721fa9/lib/keymap-helpers.nix
I think the best approach is to add a mkMapOptionSubmodule variant that omitts either key or action.
Maybe we could do something like:
mkMapOptionSubmodule = defaults: mkMapOptionSubmodule' {
hasKey = true;
hasAction = true;
inherit defaults;
};
mkMapOptionSubmodule' = {
hasKey ? false,
hasAction ? false,
rawAction ? true,
defaults ? {}
}: submodule {
options = (
(optionalAttrs hasKey {
key = mkOption (
{
type = str;
description = "The key to map.";
example = "<C-m>";
}
// (optionalAttrs (defaults ? key) { default = defaults.key; })
);
})
// (optionalAttrs hasAction {
action = mkOption (
{
type =
if rawAction
then nixvimTypes.maybeRaw str
else str;
description = "The action to execute.";
}
// (optionalAttrs (defaults ? action) { default = defaults.action; })
);
})
// {
mode = mkModeOption defaults.mode or "";
options = mapConfigOptions;
# Deprecated `lua` option omitted
}
);
}
Or since mkMapOptionSubmodule is only used by the wtf LSP and internally in keymap-helpers, we could change its interface instead of introducing a variant.