Skip to content

keymap: use nvim api for setting keymaps#94

Closed
willnorris wants to merge 1 commit intochentoast:masterfrom
willnorris:keymaps
Closed

keymap: use nvim api for setting keymaps#94
willnorris wants to merge 1 commit intochentoast:masterfrom
willnorris:keymaps

Conversation

@willnorris
Copy link
Contributor

@willnorris willnorris commented Mar 4, 2023

This allows setting a reasonable description for each mapping that will render nicely in plugins like which-key.

This is using the older vim.api.nvim_set_keymap function in order to retain compatibility with Neovim 0.5, as noted in the readme. If/when the minimum version were bumped to 0.7, this could be further simplified to:

vim.keymap.set("n", key, M[cmd], { desc = "marks: "..cmd:gsub("_", " ")  }) 

This allows setting a description for each mapping that will render
nicely in plugins like which-key.
@chentoast
Copy link
Owner

I think this patch makes sense to me. I don’t really see this plugin upgrading to vim.keymap unless there’s a specific feature that it unlocks; I prefer to keep the plugin compatible with very old versions since its already pretty mature.

@willnorris
Copy link
Contributor Author

yeah, I definitely don't think there is any reason to use vim.keymap here. And just to show the description change in which-key that I forgot in the original message...

before:
before

after:
after

@willnorris
Copy link
Contributor Author

merged in #125

@willnorris willnorris closed this May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants