-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keymap Override #31
Comments
Yes, configurable keymaps are something that is on my to do list. Its in a bad situation right now with some being end user configurable and others being hardcoded. Additionally, some are using the module system for mappings, while others are literal lua/vim code. This is due to plugins all have different ways to handle keymappings (generic lua, vim, or inside plugin setup). And it is a legacy of this project evolving form a single personal configuration. I want something standardized (hides the underlying mapping implementation) and can be overridable (ideally from the use of I am open to PRs, but I recommend staritng with a small POC so we can iterate. |
Some thoughts: In order to cater to the plugins that have a really non-trivial mapping api (e.g nvim-cmp, where one has to use
This could take shape in several forms: Define the keymap close to the plugin - mappings for each plugin are given within their respective configuration:{
autocomplete = {
enable = true;
foo = bar;
mappings = {
"<CR>" = "CmpConfirm";
"<leader>h" = "CmpDoSomethingElse";
};
};
} Maybe we could even do the actions a bit more staticaly, by making {
autocomplete = {
enable = true;
foo = bar;
mappings = actions: {
"<CR>" = actions.confirm;
"<leader>h" = actions.doSomethingElse;
"<leader>s" = someUserDefinedHack actions.insufficientlyPredefinedAction;
};
};
} where {
confirm = "cmp.mapping.confirm({select=true})";
doSomethingElse = "cmp.config.abort()";
...
} Each module calls its respective Problems that i can see immediately:
Having the keymap on one central optionSomething like keymap = {
"<CR>" = "CmpConfirm";
"<leader>e" = "FileTreeOpen";
}; I personally think we should not handle actions via strings... that just doesn't feel right. I believe we could manage to get a similar actions api going like i described above: keymap = actions: {
"<CR>" = actions.cmp.confirm;
"<leader>e" = acitons.filetree.open;
}; where each module defines something like this in their config {
config = {
actions = {
confirm = "cmp.mapping.confirm({select=true})";
doSomethingElse = "cmp.config.abort()";
...
};
};
} and then we have a seperate |
As far as I could discern there is currently no way to override the default keymap (Only extending them).
Is there a way that I have missed?
If implemented - my first idea would be to simply add some sort of "customKeymap" attrset option to each module, that if given replaces the default keymap. Is this or something similar be something that would be welcomed as a PR?
The text was updated successfully, but these errors were encountered: