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
Lua: improve vim.keymap.set() #28536
Comments
What is the objection to this? |
Personally, I don't see the claimed readability benefit, so the churn seems not worth it. And it conflicts with the (in my opinion stronger) project standard of "optional keyword-style arguments last". |
No objection from my side, but I suspect part of the objection is that in most personal keymaps people just don't set a description, so they already have: vim.keymap.set('n', 'crr', function()
vim.lsp.buf.code_action()
end) And with this change they'd have to write: vim.keymap.set('n', 'crr', nil, function()
vim.lsp.buf.code_action()
end) The nudge towards adding a description might not be the worst, but imho there's no clear advantage to the proposed change for most users. vim.keymap.set('n', 'crr', vim.lsp.buf.code_action, { desc = 'vim.lsp.buf.code_action()' }) Opposed to autocmds, keymaps don't (yet?) provide a context as argument to the called function, so using the function reference is currently save. |
good point. so instead, I have updated the proposal to be an overload instead of deprecating the old form. |
Problem
keymap.set has a suboptimal signature, it could be improved
Expected behavior
rhs
can be the last arg.function keymap.set(mode, lhs, opts, rhs)
but discouragedlhs
can be a list. This reduces boilerplate when defining aliases for a mapping.Comparison
Before:
After:
The text was updated successfully, but these errors were encountered: