-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: which-key hydra mode not working? #906
Comments
I had the same issue. I figured out that the correct usage of this is for it to be the vim.keymap.set("n", "<c-w><space>", function()
require("which-key").show({
keys = "<c-w>",
loop = true,
})
end)
|
i'm just currently using this function in my config: ---@nodoc CK_Submap_n() {{{1
---@nodoc docs {{{2
---### creates submaps
---uses |nvim_set_keymap| for setting the keymaps
---@param keymap string keymap that you want to set it to.
---@param action string stuff you want to do for the keymap
---@param submaplevel string if your keymap is is `abcd` and you want to just hit `d` after doing `abcd` to execute the keymap again, your submaplevel would be `abc`
---@param opts? {wk: boolean?, desc:string?, wait:integer?, mode:string?} --
---`wk:` nil and true are treated the same -> it executes whichkey before executing the keymap again. if false, it doesn't
---`desc:` the description from the keymap
---`wait:` time to wait before executing the keymap again. uses |vim.wait()|
---`mode`: the mode. normal mode, visual mode, insert mode etc.
---@nodoc docs }}}2
function CK_Submap(keymap, action, submaplevel, opts)
if opts == nil then
opts = {}
end
local iswhichkey = opts.wk
local description = opts.desc
local waiting_time = opts.wait
local mode = opts.mode
---@type string
local whichkey = ""
---@type string
local wait = ""
if iswhichkey == true or iswhichkey == nil then
whichkey = ":WhichKey<lt>CR>"
end
if waiting_time ~= nil and waiting_time >= 1 then
wait = "vim.wait(" .. waiting_time .. ") "
end
if mode == nil then
mode = "n"
end
vim.api.nvim_set_keymap(
mode,
keymap,
action
.. ":lua "
.. wait
.. "vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('"
.. whichkey
.. submaplevel
.. "', true, false, true), 'nt', false)<CR>",
{
noremap = true,
silent = true,
desc = description,
}
)
end -- }}}1 |
How do you use it when you are using which-key.add for your mappings already though? I've been trying to make a nested window so that I can make stepping lines in a debugger much less tedious but I have not been able to figure out how to use .show or it's loop parameter correctly in tandom with the standard .add hotkeys and the default trigger. This plugin has been wonderful but the documentation has been lacking. Been trying to look at the source code for answers but no luck yet. |
have the same issue |
show() function won't work and prompts errors. {
"folke/which-key.nvim",
event = "VeryLazy",
...
keys = {
{
"<c-w><space>",
function()
require("which-key").show({ keys = "<c-w>", loop = true })
end,
desc = "Window Hydra Mode (which-key)",
},
},
|
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 docs and existing issues?
Neovim version (nvim -v)
NVIM v0.11.0-dev-1315+g668d2569b4
Operating system/version
linux
Describe the bug
the docs tell me to do this:
but when i actually put in my config, i get this error:
Steps To Reproduce
copy paste this in the config:
Expected Behavior
the error shouldn't happen?
Health
No response
Log
No response
Repro
The text was updated successfully, but these errors were encountered: