Closed tmillr closed 1 year ago
I'm not sure if which-key already allows passing expr = true
? (which seems to be the case)
If so, it doesn't appear to be documented along with the other options.
That's already supported
Oh ok, I guess it's just not documented then
For anyone coming from the future, expr = true
support is unofficially documented in issue #67.
Did you check the docs?
Is your feature request related to a problem? Please describe.
Regular vim/nvim supports expression mappings. For one, they can be useful with conditional mappings (e.g. noremap back to the default keys/action depending upon some runtime condition, otherwise do a different action/keys). Providing this ability would make it so that you don't have to use
:normal
orfeedkeys()
within the function (i.e. the fn passed as part of the mapping definition) as a workaround.Describe the solution you'd like
Allow passing
expr = true
in mapping definition, in which case the string returned by the fn at runtime becomes the result of the mapping.Describe alternatives you've considered
using
:normal
ornvim_feedkeys()
inside the lua fnI suppose you could also resort to a vimscript command string mapping (using
<Cmd>{logic}<CR>
), but it'd be nicer to be able to write the all of the logic within an/the actual lua function instead (where syntax hl and lsp works, formatting works, you can write multiple lines easily, etc.), returning only the string/keys as the result. This probably still requires the use of:normal
or feedkeys as well. Plus,v:lua.*
within the mapping string can only be used to call global or required functions.TLDR: providing this feature would provide a cleaner, nicer and more straightforward solution,
vim.keymap.set()
allows passingexpr = true
Additional context
No response