-
-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nvim-tree does not BufWinEnter
when opening on VimEnter
#2130
Comments
Vim events will be the death of me. They are undpredictably deterministic, especially around startup. This behavour doesn't appear to be nvim-tree specific. Experimented with vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
local log = require("nvim-tree.log")
log.line("dev", "VimEnter START %s", vim.inspect(vim.opt.eventignore:get()))
vim.schedule(function()
require('nvim-tree.api').tree.toggle({ focus = false })
end)
log.line("dev", "VimEnter END %s", vim.inspect(vim.opt.eventignore:get()))
end,
}) |
Reproduce without nvim-tree vim.api.nvim_create_autocmd({ "BufWinEnter", "FileType", "WinNew", "WinResized", "WinScrolled" }, {
callback = function(event)
local log = require("nvim-tree.log")
log.line("dev", "%d %-15s %s", event.buf, event.event, event.file)
end,
})
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
local log = require("nvim-tree.log")
log.line("dev", "VimEnter START %s", vim.inspect(vim.opt.eventignore:get()))
vim.api.nvim_command "vsp"
vim.api.nvim_command "e bar"
log.line("dev", "VimEnter END %s", vim.inspect(vim.opt.eventignore:get()))
end,
})
|
Comment out VimEnter and see the missing events:
|
I see, so this isn't nvim-tree specific. Is there an upstream issue for this? For now I can just add this to the "Limitations" section of our repo, since I can see that this could affect any |
Many thanks. I'm not aware of an upstream issue. I don't think it would be possible for neovim to fix this without breaking a lot. It seems that vim legacy is holding neovim back when it comes to events. You might raise an issue / PR to update the neovim event documentation to indicate this behaviour. |
P.S. you might try a nested autocommand. My experience has been poor and I avoid them. There is the risk of infinite loops. |
Description
I am a maintainer for barbar.nvim, and we have a feature that allows users to adjust the offset of the tabline when a sidebar (such as nvim-tree) is open.
This works well most of the time, however, recently a user reported that this does not work when using the Open At Startup snippets from the wiki. Upon investigation, it appears that this is because nvim-tree does not emit a
BufWinEnter
event in this case. It is worth noting that when doing:NvimTreeToggle
afterward, it does.Neovim version
Operating system and version
6.2.10-arch1-1
nvim-tree version
48d53a5
Minimal config
It also happens with
tree.open
Steps to reproduce
nvim --clean -u minimal.lua
BufWinEnter
event is not printed on startup for theNvimTree
buffer.Expected behavior
It follows the event sequence that happens when executing
:NvimTreeToggle
after startup concludes:You can verify the above by using this snippet:
Then manually typing
:NvimTreeToggle
.Actual behavior
The text was updated successfully, but these errors were encountered: