which-key.nvim icon indicating copy to clipboard operation
which-key.nvim copied to clipboard

bug: `<Space>`, `<Tab>`, `<CR>` etc. keys are case-sensitive in `key_labels` setting

Open AlexKurisu opened this issue 1 year ago • 0 comments

Did you check docs and existing issues?

  • [x] I have read all the which-key.nvim docs
  • [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)

v0.10.0-dev-1046+g3afbf4745b

Operating system/version

ArchLinux

Describe the bug

In key_labels setting, <Space>, <Tab>, <CR> etc. key names are case-sensitive

Steps To Reproduce

  1. Set key_labels setting in which-key options, for example:
key_labels = {
	["<Space>"] = "SPC",
}
  1. Set keymap that uses said key
  2. Press prefix keys to view description of said keymap
  3. Watch as it still says <space>. Same thing would happen for other keys.

Expected Behavior

<Space> gets replaced with SPC. Same thing for other keys.

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",
	  opts = {
		  key_labels = {
			  ["<Space>"] = "SPC",
		  },
	  },
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
vim.keymap.set("n", "<Space><Space>", [[<Cmd> echo "Space!"<CR>]], { desc = "SPAAACE!!!" })

AlexKurisu avatar Sep 09 '23 12:09 AlexKurisu