Closed
Description
Description
I have a separate plugin (neoclip), which listens to TextYankPost events.
When the handler is run in neoclip, it requires regcontents to be set. neoclip code
However, looking at the nvim-tree code
It doesn't seem to set those values that are documented for the TextYankPost event.
Neovim version
NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1699801871
Operating system and version
macOS 13.6.2
Windows variant
No response
nvim-tree version
Clean room replication
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
require("packer").startup {
{
"wbthomason/packer.nvim",
"nvim-tree/nvim-tree.lua",
"nvim-tree/nvim-web-devicons",
-- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
"AckslD/nvim-neoclip.lua"
},
config = {
package_root = package_root,
compile_path = install_path .. "/plugin/packer_compiled.lua",
display = { non_interactive = true },
},
}
end
if vim.fn.isdirectory(install_path) == 0 then
print "Installing nvim-tree and dependencies."
vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true
vim.opt.cursorline = true
-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
require("neoclip").setup({ default_register = { "\"", "+", "*" } })
require("nvim-tree").setup {}
end
-- UNCOMMENT this block for diagnostics issues, substituting pattern and cmd as appropriate.
-- Requires diagnostics.enable = true in setup.
--[[
vim.api.nvim_create_autocmd("FileType", {
pattern = "lua",
callback = function()
vim.lsp.start { cmd = { "lua-language-server" } }
end,
})
]]
Steps to reproduce
- nvim -nu /tmp/nvt-min.lua
- :NvimTreeOpen
- Navigate to a file in the tree
- In normal mode, press 'y' to attempt to yank file
- Error with neoclip saying regcontents is empty
Expected behavior
Open nvim-tree, for a file in the tree, try to yank the filename with 'y'. There are no error messages that show up for handlers that read regcontents from the event.
Actual behavior
Open nvim-tree, for a file in the tree, try to yank the filename with 'y'.
Error detected while processing TextYankPost Autocommands for "*":
E5108: Error executing lua ...hare/nvim/lazy/nvim-neoclip.lua/lua/neoclip/handlers.lua:9: attempt to get length of field 'regcontents' (a nil value)
stack traceback:
...hare/nvim/lazy/nvim-neoclip.lua/lua/neoclip/handlers.lua:9: in function 'should_add'
...hare/nvim/lazy/nvim-neoclip.lua/lua/neoclip/handlers.lua:45: in function 'handle_yank_post'
[string ":lua"]:1: in main chunk
[C]: in function 'nvim_exec_autocmds'
...zy/nvim-tree.lua/lua/nvim-tree/actions/fs/copy-paste.lua:266: in function 'fn'
...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/api.lua:49: in function <...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/api.lua:46>