which-key.nvim icon indicating copy to clipboard operation
which-key.nvim copied to clipboard

bug: Keys.update_keymaps only adds, never removes

Open isakbm opened this issue 1 month ago • 3 comments

Did you check docs and existing issues?

  • [X] I have read all the which-key.nvim docs
  • [X] I have searched the existing issues of which-key.nvim
  • [X] I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1713484068

Operating system/version

Ubuntu 22.04.3 LTS

Describe the bug

When a buffer local keymap is removed, which-key will still show it as if it exists. In other words, which-key only adds buffer local keymaps to the tree, it never removes them.

Steps To Reproduce

Add the following two keymaps, the first one adds the buffer local keymap to current buffer, the second one removes it.

vim.keymap.set('n', '<leader>A', function()
  vim.keymap.set('n', '<leader>aa', function()
    print 'aa'
  end, { buffer = vim.api.nvim_get_current_buf() })
end)

vim.keymap.set('n', '<leader>S', function()
  vim.keymap.del('n', '<leader>aa', { buffer = vim.api.nvim_get_current_buf() })
end)
  1. Open some file like your init.lua.
  2. Do <leader>A
  3. Do <leader> and observe how a -> appears in the which-key help window
  4. Do <leader>S
  5. Do <leader> and observe how a -> still appears in the which-key help window

Expected Behavior

It is expected that in step 5 of the steps to reproduce, that we no longer see the keymap listed.

Repro

Just take any regular kickstart nvim config and add the key bindings from the `steps to reproduce`.

isakbm avatar Jun 29 '24 20:06 isakbm