Closed ir-ae closed 1 month ago
What do you expect to happen with that config?
You have a keymap at <leader>w
that shows and executes keymaps at <leader>w
.
If you want to make this work, just define it as a trigger. Don't manually call it since it will load that same keymap again and again.
I just added some checks that will show an error in this case.
What do you expect to happen with that config? You have a keymap at
<leader>w
that shows and executes keymaps at<leader>w
.
The idea was to have <leader>w
do something and then show the <leader>w1
/<leader>w2
commands in which-key afterwards.
vim.keymap.set("n", "<leader>w", function()
-- Do other stuff here --
require"which-key".show("<leader>w")
end)
Just defining it as a trigger doesn't allow that unless I'm missing something. I guess I was wanting a way for show()
to just show which-key without actually executing the mapping I pass to it
If you want to make this work, just define it as a trigger. Don't manually call it since it will load that same keymap again and again.
Seems not work
Here is how I managed to make my old dynamic mapping works with which-key.
which-key.extras
did.whichKey.add({ '<leader>z+', group = 'xxx', expand = function() return deep_cloned_table_of_previous_maps end })
. Note: deep clone the table then return is important.<leader>z+
keys in a strange way.
3.1 First, call it in vim.schedule(function() // call 3.2 end)
3.2 Second, must call it in vim.defer_fn(function() // trigger the keys using vim.api.nvim_feedkeys end, 1)
.Without 3, which-keys will keep report can not found keys in mode 'n'.
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.0 Build type: Release LuaJIT 2.1.1713484068
Operating system/version
Windows 10
Describe the bug
Which-key freezes if you press a button that is not displayed after calling
.show()
. Pressing<C-c>
lets you then type againSteps To Reproduce
Using the keybinds in the repro
<leader>w
1
or2
(e.gj
/k
...)<C-c>
Expected Behavior
which-key should just close the popup without freezing
Health
Log
Repro