feature: WhichKey command should display keymaps for current mode by default
Did you check the docs?
- [X] I have read all the which-key.nvim docs
Is your feature request related to a problem? Please describe.
The :WhichKey command shows the keymaps for the provided mode parameter, or for normal mode if none is specified.
This means that running the command from other modes (e.g., insert or visual) will not show the proper keymaps and we need to provide the mode explicitly, which is a bit more cumbersome, especially if the :WhichKey command is bound to a keymap.
Describe the solution you'd like
The :WhichKey command should display keymaps for the current mode if the mode parameter is not specified.
Proposed fix: change config.lua, line 313 from mode = "n" to mode = vim.api.nvim_get_mode().mode.
Describe alternatives you've considered
It's possible to configure mode-specific keymaps that run :WhichKey with the appropriate parameter. e.g., instead of:
keys = {
{
"<C-\\>",
"<cmd>WhichKey<CR>",
mode = { "n", "i", "x", "s", "o", "t", "c" },
desc = "Show keymaps (which-key)",
},
},
something along the lines of:
keys = {
{
"<C-\\>",
"<cmd>WhichKey i<CR>",
mode = "i",
desc = "Show keymaps (which-key)",
},
{
"<C-\\>",
"<cmd>WhichKey x<CR>",
mode = "x",
desc = "Show keymaps (which-key)",
},
...
},
I've also thought about using a generic mapping similar to:
{
"<C-\\>",
"':WhichKey ' . mode() . '<CR>'",
mode = { "n", "i", "x", "s", "o", "t", "c" },
desc = "Show keymaps (which-key)",
expr = true,
},
However, that doesn't work because entering a command from different modes requires different prefixes (: from normal, <C-o> from insert, need to remove the range prefix in visual mode, etc.).
These solutions are unnecessarily complex.
Additional context
No response
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 prepared https://github.com/folke/which-key.nvim/pull/932 to fix this. I tested locally and seems to work fine. I didn't find any documentation for the WhichKey command, so I don't think there's anything else that needs updating.
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.
Bump. The issue is not stale. There is a 1-line PR ready.
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.
Bump. The issue is not stale. There is a 1-line PR ready.
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.
Bump. The issue is not stale. There is a 1-line PR ready.
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.
Bump. The issue is not stale. There is a 1-line PR ready.
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.
Bump. The issue is not stale. There is a 1-line PR ready.
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.
This issue is not stale.
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.
Issue is not stale.
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.
Issue is not stale.
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.
Issue is not stale.