[X] I have searched the existing issues of which-key.nvim
[X] I have searched the existing issues of plugins related to this issue
Neovim version (nvim -v)
NVIM v0.9.0
Operating system/version
NixOS 23.05 x86_64 Linux
Describe the bug
register method fails when <leader> and <localleader> share part of the same sequence. I get the following error:
E5108: Error executing lua .../pack/packer/start/which-key.nvim/lua/which-key/util.lua:128: {
internal = { " ", "m", "a" },
keystr = "<localleader>a",
notation = { "<leader>", "a" }
}
stack traceback:
[C]: in function 'error'
.../pack/packer/start/which-key.nvim/lua/which-key/util.lua:128: in function 'parse_keys'
...k/packer/start/which-key.nvim/lua/which-key/mappings.lua:183: in function <...k/packer/start/which-key.nvim/lua/which-key/mappings.lua:171>
vim/shared.lua: in function 'parse'
.../pack/packer/start/which-key.nvim/lua/which-key/keys.lua:203: in function 'register'
.../pack/packer/start/which-key.nvim/lua/which-key/init.lua:73: in function 'register'
[string ":source (no file)"]:1: in main chunk
E5108: Error executing lua .../pack/packer/start/which-key.nvim/lua/which-key/util.lua:128: {
internal = { " ", "m", "a" },
keystr = "<localleader>a",
notation = { "<leader>", "a" }
}
stack traceback:
[C]: in function 'error'
.../pack/packer/start/which-key.nvim/lua/which-key/util.lua:128: in function 'parse_keys'
...k/packer/start/which-key.nvim/lua/which-key/mappings.lua:183: in function <...k/packer/start/which-key.nvim/lua/which-key/mappings.lua:171>
vim/shared.lua: in function 'parse'
.../pack/packer/start/which-key.nvim/lua/which-key/keys.lua:203: in function 'register'
.../pack/packer/start/which-key.nvim/lua/which-key/init.lua:73: in function 'register'
[string ":source (no file)"]:1: in main chunk
Expected Behavior
The mapping <leader>ma is set. Equivalent to:
vim.keymap.set('n', '<localleader>a', function vim.cmd('echo "hi"') end)
Repro
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
"folke/tokyonight.nvim",
"folke/which-key.nvim",
-- add any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
--- Set leader keys
vim.g.mapleader = ' '
vim.g.maplocalleader = ' m'
--- Set the keys
require('which-key').register({
a = {
function()
vim.cmd('echo "hi"')
end,
"Hello"
},
}, { prefix = '<localleader>' })
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.9.0
Operating system/version
NixOS 23.05 x86_64 Linux
Describe the bug
register
method fails when<leader>
and<localleader>
share part of the same sequence. I get the following error:Seems like [https://github.com/folke/which-key.nvim/blob/4acffc92953a90a790603bfdab7c92319ab167b1/lua/which-key/util.lua#L127-L129](this line) is what is failing.
Steps To Reproduce
leader
andlocalleader
localleader
Expected Behavior
The mapping
<leader>ma
is set. Equivalent to:Repro