From ea5b2e00bf7aeaaf10a4e93763419e4af2796782 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 12 Jul 2023 17:21:32 +0200 Subject: [PATCH] feat(loader): `LazyLoad` event with plugin name as `data` field. Useful to do stuff when a plugin loads --- README.md | 1 + lua/lazy/core/loader.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index a30e651..eb3faa1 100644 --- a/README.md +++ b/README.md @@ -582,6 +582,7 @@ The following user events will be triggered: - **LazyClean**: after a clean - **LazyCheck**: after checking for updates - **LazyLog**: after running log +- **LazyLoad**: after loading a plugin. The `data` attribute will contain the plugin name. - **LazySyncPre**: before running sync - **LazyInstallPre**: before an install - **LazyUpdatePre**: before an update diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua index 91a3f3a..ea1d143 100644 --- a/lua/lazy/core/loader.lua +++ b/lua/lazy/core/loader.lua @@ -333,6 +333,7 @@ function M._load(plugin, reason, opts) plugin._.loaded.time = Util.track().time table.remove(M.loading) vim.schedule(function() + vim.api.nvim_exec_autocmds("User", { pattern = "LazyLoad", modeline = false, data = plugin.name }) vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false }) end) end