folke / which-key.nvim

💥 Create key bindings that stick. WhichKey helps you remember your Neovim keymaps, by showing available keybindings in a popup as you type.
Apache License 2.0
4.99k stars 160 forks source link

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

Closed AlexKurisu closed 3 weeks ago

AlexKurisu commented 11 months ago

Did you check docs and existing issues?

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",
    }
  2. Set keymap that uses said key
  3. Press prefix keys to view description of said keymap
  4. 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!!!" })
github-actions[bot] commented 1 month ago

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.