Closed MattSturgeon closed 4 months ago
You can try something like this:
return {
'folke/which-key.nvim',
config = function()
local wk = require('which-key')
wk.register({
["<leader>"] = {
w = {
'<cmd>WhichKey <C-w><cr>', 'Window actions'
},
},
["gw"] = {
'<cmd>WhichKey <C-w><cr>', 'Window actions'
}
})
end
}
This is not perfect, but it will work like you expect.
You can try something like this:
`["<leader>w"] = { '<cmd>WhichKey <C-w><cr>', 'Window actions' }
This is not perfect, but it will work like you expect.
Thanks, calling :WhichKey [[action]]
manually is a decent workaround, other than which-key opening instantly (without any delay) it seems to achieve what I wanted.
I'll leave this issue open so that @folke can consider the underlying issue, feature request and/or adding the workaround example to the docs (etc).
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.
I'd still like to find a better solution, but I don't know what that might be...
Thanks! Was 4537d3ea52b2b11b96ca2fdde2bb4573f0ca7c73 the fix for this one?
For anyone else looking, the correct way to configure this now is:
require('which-key').add({
{ "<leader>w", proxy = "<C-w>", group = "window" }
})
For anyone else looking, the correct way to configure this now is:
require('which-key').add({ { "<leader>w", proxy = "<C-w>", group = "window" } })
So this fixes the problem to a degree. When directly using the <C-w>
command, every possible command isn't included in the popup. For example, <C-w> c
to close a window isn't. However, you can still use it.
With this proxy solution only commands that are in the popup work, so <leader>wc
does not work.
With this proxy solution only commands that are in the popup work, so
<leader>wc
does not work.
Can confirm, I've also noticed this behaviour.
I have yet to troubleshoot whether it is a vim or a which-key issue, though. I.e. if you had a :map <leader>w <C-w>
mapping, would <leader>wc
work correctly?
If this is an problem specific to which-key's proxy mappings, I think we ought to open a new issue to track it, though.
If this is an problem specific to which-key's proxy mappings, I think we ought to open a new issue to track it, though.
I've figured out why this is and how to fix it. In the codebase there is a mapping called window
with a set of presets when pressing <leader>w
. Not every command useable by <C-W>
is in this explicit mapping found at the following link:
However, you can add more keymaps to the window
group by defining a proxy
keymap. Here is a snippet of some I've added to the windows
group:
wk.add({
{ '<leader>w', proxy = '<c-w>', group = 'window' }, -- proxy to window mappings
{ '<c-w>c', desc = 'Close window' },
{ '<c-w>H', desc = 'move current window to the far left' },
{ '<c-w>J', desc = 'move current window to the very bottom' },
{ '<c-w>K', desc = 'move current window to the very top' },
{ '<c-w>L', desc = 'move current window to the far right' },
})
Did you check the docs?
Is your feature request related to a problem? Please describe.
When I map
"<leader>w"
to"<C-w>"
, I don't get the which-key popup for<C-w>
when typing<leader>w
.<C-w>
manually, the "wondow" mappings are displayed.<leader>w
,C^W
is shown in the status bar, however which-key's window does not appear.Describe the solution you'd like
"Alias" mappings should be detected by which-key and displayed
Describe alternatives you've considered
Alternatively, "aliases" could be manually configured during plugin setup.
e.g.
Additional context
Extra ideas: