diff --git a/README.md b/README.md index 8ac8921..2afda4d 100644 --- a/README.md +++ b/README.md @@ -519,6 +519,18 @@ require("lualine").setup({ +### 📆 User Events + +The following user events will be triggered: + +- **LazyDone**: when lazy has finished starting up and loaded your config +- **LazySync**: after running sync +- **LazyInstall**: after an install +- **LazyUpdate**: after an update +- **LazyClean**: after a clean +- **LazyCheck**: after checking for updates +- **LazyLog**: after running log + ## 🔒 Lockfile `lazy-lock.json` After every **update**, the local lockfile is updated with the installed revisions. diff --git a/TODO.md b/TODO.md index a0b7600..e291cbc 100644 --- a/TODO.md +++ b/TODO.md @@ -45,7 +45,7 @@ - [ ] package meta index (package.lua cache for all packages) - [ ] document highlight groups -- [ ] document user events +- [x] document user events - [ ] document API, like lazy.plugins() - [ ] icons diff --git a/lua/lazy/manage/init.lua b/lua/lazy/manage/init.lua index 64430ff..df30970 100644 --- a/lua/lazy/manage/init.lua +++ b/lua/lazy/manage/init.lua @@ -48,6 +48,10 @@ function M.run(ropts, opts) vim.cmd([[do User LazyRender]]) Plugin.update_state() require("lazy.manage.checker").fast_check({ report = false }) + local mode = opts.mode + if mode then + vim.cmd("do User Lazy" .. mode:sub(1, 1):upper() .. mode:sub(2)) + end end) if opts.wait then @@ -141,14 +145,27 @@ end ---@param opts? ManagerOpts function M.sync(opts) - opts = M.opts(opts, { mode = "sync" }) + opts = M.opts(opts) if opts.clear then M.clear() opts.clear = false end - M.clean(opts) - M.install(opts) - M.update(opts) + if opts.show ~= false then + vim.schedule(function() + require("lazy.view").show("sync") + end) + opts.show = false + end + local clean = M.clean(opts) + local install = M.install(opts) + local update = M.update(opts) + clean:wait(function() + install:wait(function() + update:wait(function() + vim.cmd([[do User LazySync]]) + end) + end) + end) end ---@param opts? ManagerOpts diff --git a/lua/lazy/manage/runner.lua b/lua/lazy/manage/runner.lua index 125e7ce..7e556f2 100644 --- a/lua/lazy/manage/runner.lua +++ b/lua/lazy/manage/runner.lua @@ -139,7 +139,10 @@ end ---@param cb? fun() function Runner:wait(cb) if #self._running == 0 then - return cb and cb() + if cb then + cb() + end + return self end if cb then @@ -150,6 +153,7 @@ function Runner:wait(cb) vim.wait(10) end end + return self end return Runner