-
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
Make Keymap Configurable #38
Conversation
Oh no it seems like telescope and nvim-cmp weren't formatted prior to me editing them... RIP the diffs... i hope it's still clear what i did... |
4d4015c
to
c4b260b
Compare
This pull request is currently at a usable state (tho the keymapping is not implemented for all modules yet). There is still work to be done until this can be merged, however I find myself having very little time to do any of those, so this PR can be viewed as being discontinued for now. |
Closes #31
With this draft PR i want to explore some possibilities of how an API for a configurable keymap should look like. Initially I have implemented the new api for
nvimtree
,nvimBufferLine
,lsp
andnvim-cmp
- to get a feel of the different use cases. I will continue to scan the codebase for other use-cases that I cannot yet serve with this api.The initial implementation is what I call "close to module", because the end-user has to specifiy the key-bindings next to the configuration of the module.The current implementation is "global", so there is a singluarconfig.vim.keymap
attrset, which houses every single keybinding. I found this to be cleaner, as there is no ambiguity as to where keymappings that involve multiple modules should go, and as it reduces boilerplate within the modules.In order to abstract the underlying plugins away i make use of what I call "actions", that are defined within each module. They can be used to generate normal
vim.nnoremap
style bindings (e.g nvimtree module) and also weirder lua-defined bindings (e.g the lsp module)An example end-user configuration could look like this:
I think in the end we will move towards a more "global" apiI have now moved to a "global" api, where the user can define all keybindings in a central place - to have a better overview and catch clashes earlier.Also currently there is no sensible place foractions.executeViml
if the command they are executing isn't module-specific.Open Questions
keymap.includeDefaults
switch could be an option. Maybe every action has a defined default that is used when there exist no other mappings for that action. I really don't know what would be best.Architecture
config.nvim-flake.keymapActions
to supply anactions
attrset (see below), that maps action-name to a type and an action (And later on probably also documentation etc.)mkAction
helpers.type
attribute is will be used in the next step do distinguish how mappings for this actions should be handled (normalnnoremap
or some strange lua-setup-stuff)keymap.nix
module a) extracts all mappings to actions with thevim
type and passes them tovim.[xvsnicto]noremap
and b) collects all other mappings inconfig.nvim-flake.keymappings
, which is an attrset that looks like this:lsp/default.nix
) can then accessconfig.nvim-flake.keymappings
to convert this list of mappings into lua code.I'd love to get some feedback and thoughts.