Skip to content

Commit 0bca18d

Browse files
committedJun 17, 2023
feat: added Pre events. Fixes #856. Fixes #877
1 parent 10d4371 commit 0bca18d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
 

‎README.md

+6
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,12 @@ The following user events will be triggered:
575575
- **LazyClean**: after a clean
576576
- **LazyCheck**: after checking for updates
577577
- **LazyLog**: after running log
578+
- **LazySyncPre**: before running sync
579+
- **LazyInstallPre**: before an install
580+
- **LazyUpdatePre**: before an update
581+
- **LazyCleanPre**: before a clean
582+
- **LazyCheckPre**: before checking for updates
583+
- **LazyLogPre**: before running log
578584
- **LazyReload**: triggered by change detection after reloading plugin specs
579585
- **VeryLazy**: triggered after `LazyDone` and processing `VimEnter` auto commands
580586
- **LazyVimStarted**: triggered after `UIEnter` when `require("lazy").stats().startuptime` has been calculated.

‎lua/lazy/manage/init.lua

+8-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ local M = {}
1818
function M.run(ropts, opts)
1919
opts = opts or {}
2020

21+
local mode = opts.mode
22+
local event = mode and ("Lazy" .. mode:sub(1, 1):upper() .. mode:sub(2))
23+
24+
if event then
25+
vim.api.nvim_exec_autocmds("User", { pattern = event .. "Pre", modeline = false })
26+
end
27+
2128
if opts.plugins then
2229
---@param plugin string|LazyPlugin
2330
opts.plugins = vim.tbl_map(function(plugin)
@@ -49,9 +56,7 @@ function M.run(ropts, opts)
4956
vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
5057
Plugin.update_state()
5158
require("lazy.manage.checker").fast_check({ report = false })
52-
local mode = opts.mode
53-
if mode then
54-
local event = "Lazy" .. mode:sub(1, 1):upper() .. mode:sub(2)
59+
if event then
5560
vim.api.nvim_exec_autocmds("User", { pattern = event, modeline = false })
5661
end
5762
end)

0 commit comments

Comments
 (0)
Please sign in to comment.