Reloading nvim in-place (including treesitter)

I’m trying to write a helper function that fully reloads nvim without the need of closing and reopening it, using as a base the now unmaintained nvim-reload with has some good info on the matter on it’s source code

Even after unloading all packages that starts with my namespace directory (^config), and also emulating a fresh session of neovim by triggering VimEnter i still couldn’t get it to work properly, due to:

  • Treesitter highlighting still requires a manual reload in order to kick-in
  • One of the plugins i’ve made is having problems with the reload

Some more info regarding the second problem: This pluginn keeps track of all buffers (including terminals), windows and tabpages on a table using autocommands, even though i’ve set it to run on VimEnter, it’s behavior is inconsistent, when i run my reload function with :ReloadConfig, i press Shift + L to go to the next buffers, and this triggers a debug function that prints all registered buffers and etc, at first, it seems to work, but when this debug message goes away, and packer floating window appears, it stops working

The file for this plugin can be found here on my dots repo

Any help would be hugely appreciated, thanks in advance! :slight_smile:

I am not aware of any way of “hot-reloading” Neovim in a way that guarantees a fully consistent clean state, all(!) plugins included – there are just too many moving parts and subtle interactions.

I would strongly recommend not wasting time on trying to make this work and instead reflect on what you’re trying to achieve and finding better ways to do it (for example, saving and restoring sessions after a cold restart).

1 Like

Solved! the problem was on the packer_bootstrap variable value not being reset after being set, this variable is assigned when packer is cloned from github for the first time, setting it to nil beforehand prevented packer from re-running the plugin syncing and consequently breaking the hot reloading (still don’t know why packer breaks it)

Even though the critical issue involving my plugin could be solved, hot-reloading treesitter remains a mystery, it would be something really nice to have, but not that big of a blocker