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

bug: mismatched brackets in `replace.desc` regex for `<Plug>(function name)` #842

Closed dlyongemallo closed 4 weeks ago

dlyongemallo commented 2 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

v0.10.0

Operating system/version

Ubuntu 22.04

Describe the bug

When using which-key with a plugin that display its desc as <Plug>(function name), the default config uses a regex <Plug>%(?(.*)%)? to match the (optional) brackets, but because the wildcard is greedy, the right bracket is captured. This results in the right bracket being displayed as though it were part of the description.

Steps To Reproduce

  1. Use WhichKey along with a plugin that uses the <Plug>(function name) format for keymap descriptions, such as mg979/vim-visual-multi.
  2. Open neovim and run :WhichKey.

Expected Behavior

Expected: The keymaps have descriptions such as VM-Find-Under.

Actual: The keymaps have descriptions such as VM-Find-Under).

Health

which-key: require("which-key.health").check()

- OK Most of these checks are for informational purposes only.
  WARNINGS should be treated as a warning, and don't necessarily indicate a problem with your config.
  Please |DON't| report these warnings as an issue.

Checking your config ~
- WARNING |mini.icons| is not installed
- WARNING |nvim-web-devicons| is not installed
- WARNING Keymap icon support will be limited.

Checking for issues with your mappings ~
- OK No issues reported

checking for overlapping keymaps ~
- WARNING In mode `n`, <gc> overlaps with <gcc>:
  - <gc>: Toggle comment
  - <gcc>: Toggle comment line
- OK Overlapping keymaps are only reported for informational purposes.
  This doesn't necessarily mean there is a problem with your config.

Checking for duplicate mappings ~
- OK No duplicate mappings found

Log

Debug Started for v3.13.2
{
  branch = "main",
  commit = "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0"
}
new Mode(n:1)
Trigger(add) Mode(n:1) ` ' " g` g' z= \ <C-W> ] [ g z
on_key: :
ModeChanged(n:c)
  new Mode(c:1)
  Safe(true)
Trigger(add) Mode(c:1) <C-R>
on_key: W
on_key: h
on_key: i
on_key: c
on_key: h
on_key: K
on_key: e
on_key: y
on_key: <CR>
ModeChanged(c:n)
  Unsafe(command-mode)
  suspend: Mode(n:1)
  Trigger(del) Mode(n:1) <C-W> ] [ ` z ' " g` g' z= g \
State(start): Mode(n:0) Node() { delay = 0, keys = "", mode = "n", waited = 1000 }
  update Mode(n:1)
  continue:  Mode(n:1)
  getchar
  Trigger(add) Mode(n:1) ` ' " g` g' z= \ <C-W> ] [ g z
  on_key: :
  got: :
  suspend: Mode(n:1)
  Trigger(del) Mode(n:1) <C-W> ] [ ` z ' " g` g' z= g \
  feedkeys: Mode(n:1) :
on_key: :
ModeChanged(n:c)
  Safe(true)
Trigger(add) Mode(n:1) ` ' " g` g' z= \ <C-W> ] [ g z
on_key: q
on_key: a
on_key: <CR>
ModeChanged(c:n)
  Unsafe(command-mode)
  suspend: Mode(n:1)
  Trigger(del) Mode(n:1) <C-W> ] [ ` z ' " g` g' z= g \
Trigger(add) Mode(n:1) ` ' " g` g' z= \ <C-W> ] [ g z

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 = {} },
    { "mg979/vim-visual-multi" },
  },
})
github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 4 weeks ago

This issue was closed because it has been stalled for 7 days with no activity.