feat(manage): added user events when operations finish. Fixes #135

This commit is contained in:
Folke Lemaitre 2022-12-24 11:55:42 +01:00
parent 3352fc6265
commit a36d506393
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
4 changed files with 39 additions and 6 deletions

View File

@ -519,6 +519,18 @@ require("lualine").setup({
</details>
### 📆 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.

View File

@ -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

View File

@ -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

View File

@ -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