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: Old which-key config not working upon updating to v3 #630

Closed piperinnshall closed 1 month ago

piperinnshall commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10.0-dev-3080+gefb44e0ca

Operating system/version

MacOS Sonoma 14.5

Describe the bug

After updating which-key to version 3, and restarting neovim, all of the keybinds I have configured in which-key.lua no longer work, and which-key no longer opens when i press . Which-key was working previously this day.

Steps To Reproduce

  1. Update to which-key v3
  2. Have an older which-key configuration
  3. attempt to use keybinds in the configuration

Expected Behavior

Which-key works as normal, how it has been working since it was first added to my neovim config

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",
}
require("lazy").setup({
    "folke/which-key.nvim",
    event = "VeryLazy",
    init = function()
        vim.o.timeout = true
        vim.o.timeoutlen = 300
    end,
    opts = {

    },
    config = function()
        local wk = require("which-key")
        wk.register({
            l = {
                name = "lazy",
                { "<cmd>Lazy<cr>", "Open Lazy Menu" },
            },
        },
        {
            prefix = "<leader>"
        })

    end,
})

vim.cmd.colorscheme("tokyonight")
folke commented 1 month ago

That is actually not a correct mapping? That is not correct according to the old format.

{
            l = {
                name = "lazy",
                { "<cmd>Lazy<cr>", "Open Lazy Menu" },
            },
        }

You're creating both a mapping and group at the same time for the same keybinding.

If that used to work, then that was unfortunately a bug...

folke commented 1 month ago

That actually does work, but you never call which-key setup

folke commented 1 month ago

Fixed that anyway , since it used to work like that. Thank you for reporting!