diff --git a/README.md b/README.md index 9d9e079..f6cee6b 100644 --- a/README.md +++ b/README.md @@ -575,6 +575,12 @@ The following user events will be triggered: - **LazyClean**: after a clean - **LazyCheck**: after checking for updates - **LazyLog**: after running log +- **LazySyncPre**: before running sync +- **LazyInstallPre**: before an install +- **LazyUpdatePre**: before an update +- **LazyCleanPre**: before a clean +- **LazyCheckPre**: before checking for updates +- **LazyLogPre**: before running log - **LazyReload**: triggered by change detection after reloading plugin specs - **VeryLazy**: triggered after `LazyDone` and processing `VimEnter` auto commands - **LazyVimStarted**: triggered after `UIEnter` when `require("lazy").stats().startuptime` has been calculated. diff --git a/lua/lazy/manage/init.lua b/lua/lazy/manage/init.lua index 34fc065..2c19b64 100644 --- a/lua/lazy/manage/init.lua +++ b/lua/lazy/manage/init.lua @@ -18,6 +18,13 @@ local M = {} function M.run(ropts, opts) opts = opts or {} + local mode = opts.mode + local event = mode and ("Lazy" .. mode:sub(1, 1):upper() .. mode:sub(2)) + + if event then + vim.api.nvim_exec_autocmds("User", { pattern = event .. "Pre", modeline = false }) + end + if opts.plugins then ---@param plugin string|LazyPlugin opts.plugins = vim.tbl_map(function(plugin) @@ -49,9 +56,7 @@ function M.run(ropts, opts) vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false }) Plugin.update_state() require("lazy.manage.checker").fast_check({ report = false }) - local mode = opts.mode - if mode then - local event = "Lazy" .. mode:sub(1, 1):upper() .. mode:sub(2) + if event then vim.api.nvim_exec_autocmds("User", { pattern = event, modeline = false }) end end)