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

bug: cmdheight=0 causes inconsistent behavior between `:` and `;` with whichkey mapping #591

Closed glyh closed 3 months ago

glyh commented 7 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.9.5 Build type: Release LuaJIT 2.1.1702233742

Operating system/version

Linux mechrevo 6.8.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 16 Mar 2024 17:15:35 +0000 x86_64 GNU/Linux

Describe the bug

When mapping ; to : with whichkey and setting cmdheight=0, pressing ; once won't show cmdline but pressing : once will.

Steps To Reproduce

  1. Use the repro.lua
  2. press : once, statusline disappears. press esc to go back to normal mode.
  3. press ; once, statusline won't disappear, but keep typing it will disappeaer.

Expected Behavior

The behavior of ; is the same as : when mapped against it.

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/which-key.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.o.cmdheight = 0
local wk = require('which-key')

wk.register({
  [';'] = {':', 'Enter command mode', opts = {  }},
}, {})
gnusenpai commented 4 months ago

Trying to remap : acts strange for me regardless of the cmdheight setting.