nixvim
nixvim copied to clipboard
modules/keymaps: add "buffer" option to mapConfigOptions
This allows to define buffer-local keymaps, which is specially useful when combined with keymapsOnEvents.
Is this supposed to work ?
:h nvim_set_keymap states that Optional parameters map: Accepts all |:map-arguments| as keys except <buffer>, values are booleans (default false).
And To set a buffer-local mapping, use |nvim_buf_set_keymap()|.
I tested the change with vim.keymap.set, where :h vim.keymap.set() states:
Also accepts:
• {buffer}? (`integer|boolean`) Creates buffer-local mapping,
`0` or `true` for current buffer.
A quick grep through the repo found no usages of nvim_set_keymap, only vim.keymap.set, but I could have missed something.
(I've thought about typing the option either bool int, but I don't see a use-case where setting a specific buffer number would be useful.)
A quick grep through the repo found no usages of
nvim_set_keymap, onlyvim.keymap.set, but I could have missed something.
Oh, yes, you are completely right. I had forgotten about this. We used to use nvim_set_keymap.
(I've thought about typing the option
either bool int, but I don't see a use-case where setting a specific buffer number would be useful.)
True, I don't see whether that would be useful... Any opinion @traxys @MattSturgeon ?
I've thought about typing the option
either bool int, but I don't see a use-case where setting a specific buffer number would be useful.
I assume they accept int for backwards compatibility reasons? Or do they allow specifying which buffer to create the mapping in using a buffnr?
I personally don't see the use-case, but it'd be better to match upstream typing if there's actual functionality there. Otherwise I agree, keep it simple.
I assume they accept int for backwards compatibility reasons? Or do they allow specifying which buffer to create the mapping in using a buffnr?
For me it is the latter, i.e. to give a buffer id.
I personally don't see the use-case, but it'd be better to match upstream typing if there's actual functionality there. Otherwise I agree, keep it simple.
Although it makes no sense to me to set a binding for buffer x at nix build time, I don't mind if we type it the same way as upstream. Maybe @traxys will have a stronger opinion on that.
I'd rather not expose the "int", people would be able to access it using rawLua, and it does not make sense in nixvim I think