mirror of https://github.com/folke/lazy.nvim.git
feat(manage): added user events when operations finish. Fixes #135
This commit is contained in:
parent
3352fc6265
commit
a36d506393
12
README.md
12
README.md
|
@ -519,6 +519,18 @@ require("lualine").setup({
|
||||||
|
|
||||||
</details>
|
</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`
|
## 🔒 Lockfile `lazy-lock.json`
|
||||||
|
|
||||||
After every **update**, the local lockfile is updated with the installed revisions.
|
After every **update**, the local lockfile is updated with the installed revisions.
|
||||||
|
|
2
TODO.md
2
TODO.md
|
@ -45,7 +45,7 @@
|
||||||
- [ ] package meta index (package.lua cache for all packages)
|
- [ ] package meta index (package.lua cache for all packages)
|
||||||
|
|
||||||
- [ ] document highlight groups
|
- [ ] document highlight groups
|
||||||
- [ ] document user events
|
- [x] document user events
|
||||||
- [ ] document API, like lazy.plugins()
|
- [ ] document API, like lazy.plugins()
|
||||||
- [ ] icons
|
- [ ] icons
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,10 @@ function M.run(ropts, opts)
|
||||||
vim.cmd([[do User LazyRender]])
|
vim.cmd([[do User LazyRender]])
|
||||||
Plugin.update_state()
|
Plugin.update_state()
|
||||||
require("lazy.manage.checker").fast_check({ report = false })
|
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)
|
end)
|
||||||
|
|
||||||
if opts.wait then
|
if opts.wait then
|
||||||
|
@ -141,14 +145,27 @@ end
|
||||||
|
|
||||||
---@param opts? ManagerOpts
|
---@param opts? ManagerOpts
|
||||||
function M.sync(opts)
|
function M.sync(opts)
|
||||||
opts = M.opts(opts, { mode = "sync" })
|
opts = M.opts(opts)
|
||||||
if opts.clear then
|
if opts.clear then
|
||||||
M.clear()
|
M.clear()
|
||||||
opts.clear = false
|
opts.clear = false
|
||||||
end
|
end
|
||||||
M.clean(opts)
|
if opts.show ~= false then
|
||||||
M.install(opts)
|
vim.schedule(function()
|
||||||
M.update(opts)
|
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
|
end
|
||||||
|
|
||||||
---@param opts? ManagerOpts
|
---@param opts? ManagerOpts
|
||||||
|
|
|
@ -139,7 +139,10 @@ end
|
||||||
---@param cb? fun()
|
---@param cb? fun()
|
||||||
function Runner:wait(cb)
|
function Runner:wait(cb)
|
||||||
if #self._running == 0 then
|
if #self._running == 0 then
|
||||||
return cb and cb()
|
if cb then
|
||||||
|
cb()
|
||||||
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
if cb then
|
if cb then
|
||||||
|
@ -150,6 +153,7 @@ function Runner:wait(cb)
|
||||||
vim.wait(10)
|
vim.wait(10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
return Runner
|
return Runner
|
||||||
|
|
Loading…
Reference in New Issue