echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.47k stars 175 forks source link

Error when executing <C-w><C-d> #887

Closed jwtouron closed 1 month ago

jwtouron commented 1 month ago

Contributing guidelines

Module(s)

mini.clue

Description

After updating to version 0.10, and executing the new functionality for viewing diagnostics (\<C-w>d), I get the following error:

E5108: Error executing lua: .../.local/share/nvim/lazy/mini.clue/lua/mini/clue.lua:1552: Invalid 'window': Expected Lua number
stack traceback:
    [C]: in function 'nvim_win_call'
    .../.local/share/nvim/lazy/mini.clue/lua/mini/clue.lua:1552: in function 'window_scroll'
    .../.local/share/nvim/lazy/mini.clue/lua/mini/clue.lua:1321: in function 'state_advance'
    .../.local/share/nvim/lazy/mini.clue/lua/mini/clue.lua:1277: in function <.../.local/share/nvim/lazy/mini.clue/lua/mini/clue.lua:1260>

Neovim version

0.10

Steps to reproduce

  1. Update to version 0.10
  2. Install mini.clue
  3. Place cursor over LSP diagnostic location
  4. Hit \<C-w>d

Expected behavior

Show diagnostic popup.

Actual behavior

Above error message.

echasnovski commented 1 month ago

Thanks for the issue!

Unfortunately, I can not reproduce: neither with my own full config nor with minimal one containing only 'mini.clue' and 'nvim-lspconfig'.

Would you mind posting a more detailed reproduction setup? With minimal config with which you can reproduce this.

jwtouron commented 1 month ago

Thank you for looking into this. As a minimal example, I was able to reproduce the bug with this init.lua being the only file in my nvim directory, and then hitting \<C-w>\<C-d>:

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
  "echasnovski/mini.clue",
  version = '*',
  config = function()
    local miniclue = require('mini.clue')
    require('mini.clue').setup {
      triggers = {
        { mode = 'n', keys = '<C-w>' },
      },
      clues = {
        miniclue.gen_clues.windows(),
      },
    }
  end
})

Also, it appears I misspoke earlier. I didn't get an error when hitting \<C-w>d, but I did get the error when hitting \<C-w>\<C-d>.

echasnovski commented 1 month ago

Also, it appears I misspoke earlier. I didn't get an error when hitting d, but I did get the error when hitting .

Ah, that is more like it. Yes, I can reproduce now.

The reason seems to be because <C-d> is a default mapping to scroll inside clue window. I'll take a look.

echasnovski commented 1 month ago

This should now be fixed on latest main.

Important note: scroll keys (<C-d> and <C-u> by default) are still treated as special keys (same as <CR>, <BS>, and <C-c>) but only when clue window is visible. So even if they can advance key state, they will work like this:

So to use <C-w><C-d> (which is built-in on Neovim>=0.10), press <C-d> before clue window is shown. Or configure other scrolling keys.

jwtouron commented 1 month ago

Thank you for taking care of this!