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: Recursion Detected Error #809

Open Spencerduran opened 1 month ago

Spencerduran commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.10.1

Operating system/version

Sonoma 14.5

Describe the bug

When holding j or k to navigate cursor up or down, after about 20 lines this error occurs over and over again:

"Recursion detected. Are you manually loading which-key in a keymap? Use opts.triggers instead. Please check the docs."

require("which-key").setup({}) local wk = require("which-key") wk.add({ })

Steps To Reproduce

Open any file, hold j or k to scroll towards bottom of page.

Expected Behavior

No error should occur

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`, <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

BufNew(285)
  BufNew(286)
  BufNew(287)
  BufNew(288)
  BufNew(289)
  BufNew(290)
  BufEnter(289)
    new Mode(n:289)
  ModeChanged(n:i)
    new Mode(i:289)
    Unsafe(pending "<80>")
    suspend: Mode(i:289)
  Trigger(add) Mode(n:289) ' ` " g' g` z= <Plug> g z ] [ <Space> <C-W>
  Trigger(add) Mode(n:11) ' ` " g' g` z= <Plug> g z ] [ <Space> <C-W>
  BufNew(291)
  on_key: <CR>
  BufNew(292)
  on_key: c
  BufNew(293)
  on_key: o
  on_key: n
  on_key: <CR>
  on_key: w
  BufNew(294)
  on_key: k
  on_key: <CR>

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

can't reproduce are you missing something in your repro?

leevs commented 1 month ago

I have the same issue, when this happens when opening a file and scrolling down +50lines. It gets stuck and get ""Recursion detected. Are you manually loading which-key in a keymap? Use opts.triggers instead. Please check the docs."

After downgrading to v3.10.0 I can say it's resolved and the issue seems to be in v3.11.0 - in more detail: https://github.com/folke/which-key.nvim/commit/55fa07fbbd8a4c6d75399b1d1f9005d146cda22c

max397574 commented 1 month ago

did you by any chance map j to something?

Spencerduran commented 1 month ago

For me, I have "jk" mapped to escape while in insert mode, but that's the only "j" mapping i have

local default_options = { silent = true }
------------ Insert ------------
-- Press jk fast to enter normal
map("i", "jk", "<ESC>", default_options)

the thing is, this happens with scrolling up as well

leevs commented 4 weeks ago

@max397574 you are right, I had the following bindings:

-- Remap for dealing with word wrap
-- vim.api.nvim_set_keymap('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
-- vim.api.nvim_set_keymap('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })

However this never caused an issue before, does this somehow overload the buffer? Removing the bindings and going back to the latest version solved it for me.

horror-proton commented 1 week ago

can't reproduce are you missing something in your repro?

I can reproduce it with a nvim-scrollview plugin installed

{
    "dstein64/nvim-scrollview",
    config = function()
        require('scrollview').setup({
                signs_on_startup = { 'all' }
            })
    end,
},

which for some reason causing nvim to emit ModeChange event when j was pressed in visual mode.