Open traxys opened 1 year ago
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.
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)
keymaps
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 supportsmodes
as 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 usemkMapOptionSubmodule
though.)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 tomkMapOptionSubmodule
without 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.enable
toggle!)plugins.obsidian.settings.mappings
(uses a similar submodule tomkMapOptionSubmodule
, but hasopts
instead 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
plugins.wtf.keymaps.ai
plugins.wtf.keymaps.search