Closed theherk closed 3 months ago
Not sure if my scenario is the same as yours, but I have some git/lsp keymaps that don't get set until I open the file and start the LSP server, etc. For those keymaps, I register them for the buffer using an autocmd:
Simplified example:
vim.api.nvim_create_autocmd(
'LspAttach',
{ callback = function(ev)
-- define your keymaps here
vim.keymap.set(...)
-- register the buffer local keymaps
require('which-key').register({ ['<leader>f' = { name = '+foo' } }, { buffer = ev.buf })
end
})
I may be misunderstanding your issue. For me, the empty menu items wouldn't show up until I added keymaps and the the name was missing and would show '+prefix' instead.
I've come around using this workaround. When I want to register a group name, I make a dummy binding with a key that I will never press like this unicode.
wk.register({
["<localleader>"] = {
s = { name = "+send", ["🚫"] = "which_key_ignore" },
v = { name = "+view", ["🚫"] = "which_key_ignore" },
},
})
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Did you check the docs?
Is your feature request related to a problem? Please describe.
I'm guessing like many other things this is possible, and I'm overlooking it. In neorg for example there are some default keys set for localleader using another method. Their key descriptions are picked up correctly by which key, but there are no labels.
Describe the solution you'd like
What I'd like to do is simply:
But this doesn't seem to work without any other bindings contained. If I add even one, it does work and the remaining defaults are intact, but that is a bit redundant.
Describe alternatives you've considered
The alternative I use, is simply setting all the mappings again:
Additional context
I've run into this elsewhere too; where a plugin provides default keys with perfect descriptions, but I don't seem to be able to register the groups containing them without resetting the bindings.