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.43k stars 177 forks source link

bug: bindings with expr=true don't display text in command line #881

Open macovsky opened 1 week ago

macovsky commented 1 week ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.10.2

Operating system/version

linux/macos

Describe the bug

bindings with expr=true don't display text in command line

with minimal repro.lua there's just no visible text in the command line

with my own config text appears only after i press <left> for example (on both linux/macos)

Steps To Reproduce

  1. nvim -u repro.lua
  2. <space>w—you see nothing in command line but if you press for example <left> you see cursor on top of nothing
  3. although after <cr> you'll see that command was executed

Expected Behavior

should work as <space>k—text and cursor in command line should be visible right away

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
    },
})

require("which-key").add({
    {
        "<space>w",
        function()
            return ":set ft?"
        end,
        expr = true,
        desc = "expr from wk",
    },
})

vim.keymap.set("n", "<space>k", function()
    return ":set ft?"
end, { expr = true, desc = "expr from keymap" })