lukas-reineke / indent-blankline.nvim

Indent guides for Neovim
MIT License
4.09k stars 101 forks source link

VimEnter hook will be never executed when lazy-loading #915

Closed dzirtusss closed 1 month ago

dzirtusss commented 1 month ago

Problem

Currently refresh_all code is triggeref by VimEnter event, which in case of lazy-loading, will happen far-far earlier when actual plugin code will run.

Dunno how much this is important to plugin code, just stumbled upon when checkin my local VimEnter hooks.

Steps to reproduce

https://github.com/lukas-reineke/indent-blankline.nvim/blob/master/lua/ibl/autocmds.lua#L9

Expected behavior

Overall, I guess plugins should not rely on VimEnter if possible, as this doesn't work with lazy loading, which... is more common in recent configs than before.

Neovim version (nvim -v)

NVIM v0.10.1

lukas-reineke commented 1 month ago

This is working as intended. That refresh_all call is explicitly only needed when not lazy loading. In that case, the plugin initializes before all the buffers are ready, so we need to call refresh after VimEnter. For lazy loading, the call to refresh from the setup function is enough. https://github.com/lukas-reineke/indent-blankline.nvim/blob/dddb5d21811c319eb6e51a993d8fb44b193aae3f/lua/ibl/init.lua#L44