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
5.12k stars 163 forks source link

bug: some mappings with description are not shown. #769

Closed prss-ad closed 1 month ago

prss-ad commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.11.0-dev-470+gadef830f8

Operating system/version

fedora 40

Describe the bug

Just take a look at the repro.lua below. After mapping 'yA' and 'yL', when pressing 'y' , menu for yanking shows up but 'A' and 'L' are not present. Likewise remapping 'T' to a new command works , but the default description is still shown.

Steps To Reproduce

nvim -u repro.lua press 'y' verify 'A' and 'L' are missing. press press verify description for T is still 'break out into new tab'

Expected Behavior

Expect mapping to be visible with correct description.

Health

No response

Log

No response

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
    spec = {
        { "folke/which-key.nvim", opts = {} },
        -- add any other plugins here
    },
})

vim.keymap.set({ "n" }, "yA", "<cmd>%y+<cr>", { desc = "Yank file content" })
vim.keymap.set({ "n" }, "<c-w>T", "<cmd>tab split<cr>", { desc = "Show in new tab" })
local wk = require("which-key")
wk.add({
  { "yL", "<cmd>%y+<cr>", desc = "Yank file content"  },
})
folke commented 1 month ago

I've now changed the order so that preset mappings never override any existing keymap descriptions.