neo-tree.nvim
neo-tree.nvim copied to clipboard
BUG: WinEnter/BufEnter are not fired after closure of Neo-tree buffer
Did you check docs and existing issues?
- [X] I have read all the docs.
- [X] I have searched the existing issues.
- [X] I have searched the existing discussions.
Neovim Version (nvim -v)
NVIM v0.10.0-dev-ebe489d
Operating System / Version
Arch Linux
Describe the Bug
When I close the Neo-tree window (with :bd), none of the Window/Buffer enter events are fired. I suspect this has something to do with the focus stealer but I am not really sure.
Screenshots, Traceback
No response
Steps to Reproduce
- Load minimal configuration (
nvim --clean -u repro.lua) - Execute
:Neotreecommand - Execute
:bdcommand - See nothing print out on closure of Neo-tree buffer
Expected Behavior
WinEnter/BufEnter events are properly fired so they can be captured in other plugins
Your Configuration
-- Minimal configuration
-- mini.lua
-- Use with the --clean -u flags. EG nvim --clean -u mini.lua
-- Setting some basic vim options
-- Some junk because I am sick of formatting tables in print
local _print = _G.print
local clean_string = function(...)
local args = { n = select("#", ...), ... }
local formatted_args = {}
for i=1, args.n do
local item = select(i, ...)
if not item then item = 'nil' end
local t_type = type(item)
if t_type == 'table' or t_type == 'function' or t_type == 'userdata' then
item = vim.inspect(item)
end
table.insert(formatted_args, item)
end
return table.concat(formatted_args, ' ')
end
_G.print = function(...)
_print(clean_string(...))
end
vim.opt.mouse = 'a'
vim.opt.termguicolors = true
local root = vim.fn.fnamemodify("./.repro", ":p")
-- DO NOT change the paths and don't remove the colorscheme
-- 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",
-- add any other plugins here
}
local neotree_config = {
"nvim-neo-tree/neo-tree.nvim",
dependencies = { "MunifTanjim/nui.nvim", "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim" },
cmd = { "Neotree" },
keys = {
{ "<Leader>e", "<Cmd>Neotree<CR>" }, -- change or remove this line if relevant.
},
opts = {
-- Your config here
-- ...
},
}
vim.api.nvim_create_autocmd({'WinEnter', 'BufWinEnter', 'BufEnter'}, {
callback = function(details)
print(string.format("%s on buffer %s", details.event, details.buf))
end
})
table.insert(plugins, neotree_config)
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
Related:
- #571
Its an older issue so instead of necroing it, I created a reproducible configuration and created a new issue
I am also facing this issue. Are there any workarounds or fixes for this?
The reason is from nui:
https://github.com/MunifTanjim/nui.nvim/blob/756c59f46057cd2d43619cd3a6d4e01b2aa60295/lua/nui/split/init.lua#L241-L247
I don't know how to fix this. Let me dig in deeper.
I don't know how to fix this. Let me dig in deeper.
It might have missing nested = true flag to allow other events to get triggered when callback from this one is being executed.
I don't know how to fix this. Let me dig in deeper.
It might have missing
nested = trueflag to allow other events to get triggered when callback from this one is being executed.
Bingo! Thanks @echasnovski
~~Looks like we both forgot nested so it was hard to debug lol~~
No it was nui's fault. I'll make a PR upstream.
Merged upstream.
@echasnovski Could you check out the latest nui and test if the issue with mini.statusline is fixed?
Yes, it does work with current main branch of 'mini.nvim'. There were also some recent changes (two days ago, it seems) on 'mini.statusline' end that made it all work.
Glad to hear that. Thanks for having your time @echasnovski !!
Great work BTW ;)