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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: <c-d> <c-u> scrolling is not working when neoscroll.nvim is enabled

den-is opened this issue · comments

Did you check docs and existing issues?

  • I have read all the which-key.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of which-key.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

v0.10.1

Operating system/version

MacOS 14.5

Describe the bug

I was trying to figure out why <c-d> <c-u> scrolling is not working.
I have tried to setup other keymappings for scrolling <c-j> <c-k> - no luck.

Browsing through my plugins discovered that I have neoscroll enabled.
Disabling neoscroll fixed issue with which-key window scrolling.

I created issues in both repos. I hope which-key will learn how to work with neoscroll, or neoscroll will somehow will ignore/disable smooth scrolling for which-key.
Issue in neoscroll repo: karb94/neoscroll.nvim#111

Steps To Reproduce

  1. Install which-key using lazy
  2. Enable which-key listing key map <leader-?>
  3. Install neoscroll.nvim using lazy
  4. Restart nvim
  5. Call which-key listing <leader-?> - try to scroll with
  6. which-key window won't scroll. which-key window will close.

Expected Behavior

which-key's multi-page windows scrolling with neoscroll plugin enabled should work.

Health

No response

Log

No response

Repro

----
----
----  RESIZE NEOVIM WINDOW DURING TESTING
----  MAKE IT IS SMALL IN HEIGHT AS POSSIBLE
----  THIS WILL ENABLE SCROLL KEYS FOR WHICH-KEY
----
----  BY DEFAULT neoscroll enabled=true - scroll will not work
----  SET neoscroll enabled=false - scroll will work
----

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

vim.g.mapleader = " "
vim.g.maplocalleader = " "

local map = vim.keymap

map.set("n", "<leader>w", "<CMD>write<CR>", { desc = "Save/write buffer" })
map.set("n", "<leader>q", "<CMD>quit<CR>", { desc = "Quit buffer" })
map.set("i", "jj", "<ESC>", { desc = "Exit insert mode with jj" })

-- Check if have highlight enabled at all. See `:help hlsearch`
map.set("n", "<Esc>", "<CMD>nohlsearch<CR>", { desc = "Clear search highlights" })

-- Indentations
map.set("v", "<", "<gv")
map.set("v", ">", ">gv")

-- Select previous paste
map.set("n", "gp", "`[v`]", { desc = "Select previous paste" })

-- Select all
map.set("n", "<C-a>", "gg<S-v>G", { desc = "Select all" })

-- increment/decrement numbers
map.set("n", "<leader>+", "<C-a>", { desc = "Increment number" })
map.set("n", "<leader>-", "<C-x>", { desc = "Decrement number" })

-- Window management
map.set("n", "<leader>sv", "<cmd>vsplit<CR>", { desc = "Split window vertically" })
map.set("n", "<leader>sh", "<cmd>split<CR>", { desc = "Split window horizontally" })
map.set("n", "<leader>se", "<C-w>=", { desc = "Make splits equal size" })
map.set("n", "<leader>sx", "<cmd>close<CR>", { desc = "Close current split" })

-- Keybinds to make split navigation easier.
--  Use CTRL+<hjkl> to switch between windows
--
--  See `:help wincmd` for a list of all window commands
map.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" })
map.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
map.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
map.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })

-- Tabs management
map.set("n", "<leader>to", "<cmd>tabnew<CR>", { desc = "Open new tab" })
map.set("n", "<leader>tx", "<cmd>tabclose<CR>", { desc = "Close current tab" })
map.set("n", "<leader>tn", "<cmd>tabn<CR>", { desc = "Go to next tab" })
map.set("n", "<leader>tp", "<cmd>tabp<CR>", { desc = "Go to previous tab" })
map.set("n", "<leader>tf", "<cmd>tabnew %<CR>", { desc = "Open current buffer in a new tab" })

-- Buffers management
-- Also don't forget about <C-i> and <C-o> to go forward/backward in the jumplist
map.set("n", "<Tab>", "<cmd>bnext<CR>", { desc = "Go to next buffer" })
map.set("n", "<S-Tab>", "<cmd>bprevious<CR>", { desc = "Go to previous buffer" })


map.set("n", "<leader>-1", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-2", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-3", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-4", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-5", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-6", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-7", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-8", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-9", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-a", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-b", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-c", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-d", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-e", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-f", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-f", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-g", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-i", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-j", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-k", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-l", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-m", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-n", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-o", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-p", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-q", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-r", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-s", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-t", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-u", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-v", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-w", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-x", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-y", "<cmd>lua vim.print('hello')", { desc = "fake key" })
map.set("n", "<leader>-z", "<cmd>lua vim.print('hello')", { desc = "fake key" })

require("lazy.minit").repro({
  spec = {
    {
      "folke/which-key.nvim",
      event = "VeryLazy",
      opts = {
        -- your configuration comes here
        -- or leave it empty to use the default settings
        -- refer to the configuration section below
      },
      init = function()
        vim.o.timeout = true
        vim.o.timeoutlen = 500
      end,
      keys = {
        {
          "<leader>?",
          function()
            require("which-key").show({ global = false })
          end,
          desc = "Buffer Local Keymaps (which-key)",
        },
      },
    },
    {
      "karb94/neoscroll.nvim",
      enabled = true,
      opts = {},
    },
  },
})

I encountered the same bug in Ubuntu 22.04.

I don't think this is which-key bug as I had the same behaviour without having the mentioned plugin installed but with custom mapping for <C-d>/<C-u>.
Fixed it by adding buffer = true so it looks like this:
vim.keymap.set('n', '<C-d>', '<C-d>zz', { desc = 'Jump half page down', buffer = true })