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: Error detected while processing ModeChanged Autocommands #758

Closed dvonessen closed 1 month ago

dvonessen commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.9.5

Operating system/version

MacOS 14.5

Describe the bug

Error detected while processing ModeChanged Autocommands for "*": Error executing lua callback: .../share/nvim/lazy/which-key.nvim/lua/which-key/config.lua:38: attempt to call field 'list_contains' (a nil value) stack traceback: .../share/nvim/lazy/which-key.nvim/lua/which-key/config.lua:38: in function 'defer' ...l/share/nvim/lazy/which-key.nvim/lua/which-key/state.lua:115: in function <...l/share/nvim/lazy/which-key.nvim/lua/which-key/state.lua:93>

Steps To Reproduce

Expected Behavior

Line gets yanked no error shown.

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 ~
- OK |mini.icons| is installed
- WARNING |nvim-web-devicons| is not installed

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

checking for overlapping keymaps ~
- WARNING In mode `n`, <sh> overlaps with <shl>, <shn>:
  - <sh>: Highlight surrounding
  - <shl>: Highlight previous surrounding
  - <shn>: Highlight next surrounding
- WARNING In mode `n`, <sr> overlaps with <srl>, <srn>:
  - <sr>: Replace surrounding
  - <srl>: Replace previous surrounding
  - <srn>: Replace next surrounding
- WARNING In mode `n`, <sd> overlaps with <sdl>, <sdn>:
  - <sd>: Delete surrounding
  - <sdl>: Delete previous surrounding
  - <sdn>: Delete next surrounding
- WARNING In mode `n`, <sF> overlaps with <sFl>, <sFn>:
  - <sF>: Find left surrounding
  - <sFl>: Find previous left surrounding
  - <sFn>: Find next left surrounding
- WARNING In mode `n`, <sf> overlaps with <sfl>, <sfn>:
  - <sf>: Find right surrounding
  - <sfl>: Find previous right surrounding
  - <sfn>: Find next right surrounding
- WARNING In mode `n`, <gb> overlaps with <gbc>:
  - <gb>: Comment toggle blockwise
  - <gbc>: Comment toggle current block
- WARNING In mode `n`, <gc> overlaps with <gcA>, <gco>, <gcc>, <gcO>:
  - <gc>: Comment toggle linewise
  - <gcA>: Comment insert end of line
  - <gco>: Comment insert below
  - <gcc>: Comment toggle current line
  - <gcO>: Comment insert above
- WARNING In mode `x`, <i> overlaps with <il>, <in>:
  - <i>: inside
  - <il>: Inside last textobject
  - <in>: Inside next textobject
- WARNING In mode `x`, <a> overlaps with <al>, <an>, <a%>:
  - <a>: around
  - <al>: Around last textobject
  - <an>: Around next textobject
- WARNING In mode `o`, <i> overlaps with <il>, <in>:
  - <i>: inside
  - <il>: Inside last textobject
  - <in>: Inside next textobject
- WARNING In mode `o`, <a> overlaps with <al>, <an>:
  - <a>: around
  - <al>: Around last textobject
  - <an>: Around next textobject
- 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.9.0
new Mode(n:1)
Trigger(add) Mode(n:1) ` ' " z= g' g` z <C-W> ] [ g
State(start): Mode(n:0) Node(z) { keys = "z", waited = 0 }
  update Mode(n:1)
  continue: z Mode(n:1)
  getchar
  got: z
  suspend: Mode(n:1)
  Trigger(del) Mode(n:1) z <C-W> ] [ ` ' " z= g g' g`
  feedkeys: Mode(n:1) zz
Trigger(add) Mode(n:1) ` ' " z= g' g` z <C-W> ] [ g
State(start): Mode(n:0) Node(z) { keys = "z", waited = 0 }
  update Mode(n:1)
  continue: z Mode(n:1)
  getchar
  got: z
  suspend: Mode(n:1)
  Trigger(del) Mode(n:1) z <C-W> ] [ ` ' " z= g g' g`
  feedkeys: Mode(n:1) zz
Trigger(add) Mode(n:1) ` ' " z= g' g` z <C-W> ] [ g
ModeChanged(n:no)
  new Mode(o:1)
  Safe(true)
  ModeChanged(no:n)
    Safe(true)
  Trigger(add) Mode(o:1) ] [ g
  ModeChanged(n:c)
    new Mode(c:1)
    Safe(true)
  Trigger(add) Mode(c:1) <C-R>
  ModeChanged(c:n)
    Unsafe(command-mode)
    suspend: Mode(n:1)
    Trigger(del) Mode(n:1) z <C-W> ] [ ` ' " z= g g' g`
  Trigger(add) Mode(n:1) ` ' " z= g' g` z <C-W> ] [ g

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

Your Neovim installation is messed up. vim.list_contains has been around for ages...

folke commented 1 month ago

However, I can reproduce this. Weird. Will check

folke commented 1 month ago

loosk like I was wrong. It was renamed from tbl_contains to list_contains

dvonessen commented 1 month ago

Thank you fixing this that fast. 🚀