flash.nvim icon indicating copy to clipboard operation
flash.nvim copied to clipboard

bug: Interaction between flash.nvim and which-key.nvim Causing Error During Remote Yank

Open tummetott opened this issue 1 year ago • 0 comments

Did you check docs and existing issues?

  • [X] I have read all the flash.nvim docs
  • [X] I have searched the existing issues of flash.nvim
  • [X] I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.9.4 Build type: Release LuaJIT 2.1.1696795921

Operating system/version

MacOs 13.4.1

Describe the bug

Hello,

It took me some time to replicate this bug using a minimal configuration, but I successfully narrowed it down. The error occurs during a remote yank with flash.nvim while utilizing which-key.nvim. In essence, the which-key popup help seems to impact the flash operation.

Notably, this issue is only reproducible when a local keymap description (or group description) is registered with which-key (refer to repo.lua).

Steps To Reproduce

  1. Run nvim -u repo.lua test.txt
  2. Goto insert mode and type: test<cr>
  3. Perform a remote yank: <esc> y r t <cr> e
  4. Repeat step 3 again

Error

Error executing vim.schedule lua callback: vim/keymap.lua:0: E31: No such mapping
stack traceback:
        [C]: in function 'nvim_del_keymap'
        vim/keymap.lua: in function 'del'
...flash.nvim/lua/flash/jump.lua:116: in function <...flash.nvim/lua/flash/jump.lua:63>

Expected Behavior

No error should occur

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    "folke/tokyonight.nvim",
    {
        "folke/flash.nvim",
        opts = {},
        keys = {
            { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
        }
    },
    {
        "folke/which-key.nvim",
        opts = {},
    },
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")

require('which-key').register({ y = { 'y', 'yank' } })
require('which-key').register({ yo = 'local description' }, { buffer = 0 })

tummetott avatar Nov 09 '23 15:11 tummetott