folke / lazy.nvim

💤 A modern plugin manager for Neovim
https://lazy.folke.io/
Apache License 2.0
15.02k stars 365 forks source link

feature: add user event 'LazyReload' #178

Closed ryuheechul closed 1 year ago

ryuheechul commented 1 year ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

I would like to subscribe the changes made via lazy.nvim programmatically. Currently there is an option change_detection.notify = true to get notified when lazy detected the changes and reloaded but this is only through :messages not via autocmd User event.

Describe the solution you'd like

Fire some user event around https://github.com/folke/lazy.nvim/blob/bb53b8473cd065dc467853222ee3462739ab16fa/lua/lazy/manage/reloader.lua#L83 that is not LazyRender

Describe alternatives you've considered

going even further with LazyReloadPre and LazyReloadPost

Additional context

My ultimate goal is to to see if it's possible to re-run config functions after reload so that it's possible to "refresh" neovim with updated config without restarting neovim.

(It would be nice if lazy.nvim provide such feature eventually but currently I'm just experimenting)

I personally acheived this few days ago for packer by writing this file https://github.com/ryuheechul/dotfiles/blob/nvim-packer/nvim/lua/utils/packer-auto-compile.lua

related links:

folke commented 1 year ago

I just added LazyReload. Not planning to make lazy reloadable since that is not 100% possible in all cases.