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: `gcc` does not toggle comment in new buffer unless activated through which-key #791

Closed echaya closed 1 month ago

echaya commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10

Operating system/version

Win 10

Describe the bug

Using nvim 0.10's native gcc in normal mode will toggle comments. When using which-key, gcc does not toggle comments reliable.

Running gcc will flash O-pending mode and does not toggle comment.

To make it work, for each buffer I enter, I need to press g and wait for the pop-up and then press cc to toggle comment. After that, gcc works as expected.

I see this issue only happens to lua and vimrc files but not python which I have lsp running. I see similar issue here hence raise as a new issue

Steps To Reproduce

  1. Enter .vimrc or any file that does not have lsp configured.
  2. Press gcc to toggle a line

Expected Behavior

As I'm new to this plug-in, I don't know how exact it is worked. My current impression is undergoing g => which-key pop-up => cc will "register" the keymap to make it work in the same buffer Without this step, whick-key triggers O-pending mode by gc and cancelled by the 3rd c although keystrokes were pressed within milliseconds.

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
- OK |nvim-web-devicons| is installed

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

checking for overlapping keymaps ~
- WARNING In mode `n`, <d> overlaps with <dd>, <dmm>, <d<C-X>>, <ds>, <d<C-A>>:
  - <d>: Delete
  - <ds>: Delete a surrounding pair
- WARNING In mode `n`, <x> overlaps with <xx>:

- WARNING In mode `n`, <c> overlaps with <cS>, <cs>, <cc>:
  - <c>: Change
  - <cS>: Change a surrounding pair, putting replacements on new lines
  - <cs>: Change a surrounding pair
- WARNING In mode `n`, <m> overlaps with <mi>, <mk>, <mj>, <mm>:

- WARNING In mode `n`, <gc> overlaps with <gcc>:
  - <gc>: Toggle comment
  - <gcc>: Toggle comment line
- WARNING In mode `n`, <yS> overlaps with <ySS>:
  - <yS>: Add a surrounding pair around a motion, on new lines (normal mode)
  - <ySS>: Add a surrounding pair around the current line, on new lines (normal mode)
- WARNING In mode `n`, <ys> overlaps with <yss>:
  - <ys>: Add a surrounding pair around a motion (normal mode)
  - <yss>: Add a surrounding pair around the current line (normal mode)
- WARNING In mode `i`, <;> overlaps with <;it>, <;f>, <;ct>, <;cb>:

- WARNING In mode `s`, <<Space>> overlaps with <<Space>o>, <<Space>p>:

- WARNING In mode `s`, <g> overlaps with <gZ>:

- WARNING In mode `s`, <h> overlaps with <hs>, <hu>:
  - <hu>: undo_stage_hunk
- 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.12.0
new Mode(n:1)
Trigger(add) Mode(n:1) " ' ` g' g` z= Z g z = [ <Space> <C-W> ] dm
on_key: 1
ModeChanged(n:c)
  new Mode(c:1)
  Unsafe(pending "c")
  suspend: Mode(c:1)
ModeChanged(c:n)
  cooldown
BufNew(3)

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
  },
})
folke commented 1 month ago

Can't reproduce this with the repro. The repro will automatically use the latest which-key version. Are you 100% certain your plugins are up to date?

echaya commented 1 month ago

Update my plugins again, can no longer repro. Thank you!