diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua index 663a6da..e5f727a 100644 --- a/lua/lazy/core/loader.lua +++ b/lua/lazy/core/loader.lua @@ -227,7 +227,7 @@ function M._load(plugin, reason, opts) plugin._.loaded.time = Util.track().time table.remove(M.loading) vim.schedule(function() - vim.cmd("do User LazyRender") + vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false }) end) end diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua index 8a937a8..bc7720d 100644 --- a/lua/lazy/core/util.lua +++ b/lua/lazy/core/util.lua @@ -143,7 +143,7 @@ function M.very_lazy() local function _load() vim.schedule(function() vim.g.did_very_lazy = true - vim.cmd("do User VeryLazy") + vim.api.nvim_exec_autocmds("User", { pattern = "VeryLazy", modeline = false }) end) end diff --git a/lua/lazy/init.lua b/lua/lazy/init.lua index d3b8b93..a0b073a 100644 --- a/lua/lazy/init.lua +++ b/lua/lazy/init.lua @@ -64,7 +64,7 @@ function M.setup(spec, opts) Loader.startup() -- all done! - vim.cmd("do User LazyDone") + vim.api.nvim_exec_autocmds("User", { pattern = "LazyDone", modeline = false }) require("lazy.stats").track("LazyDone") end diff --git a/lua/lazy/manage/init.lua b/lua/lazy/manage/init.lua index d14a7b8..9ffda73 100644 --- a/lua/lazy/manage/init.lua +++ b/lua/lazy/manage/init.lua @@ -42,16 +42,17 @@ function M.run(ropts, opts) local runner = Runner.new(ropts) runner:start() - vim.cmd([[do User LazyRender]]) + vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false }) -- wait for post-install to finish runner:wait(function() - vim.cmd([[do User LazyRender]]) + 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 - vim.cmd("do User Lazy" .. mode:sub(1, 1):upper() .. mode:sub(2)) + local event = "Lazy" .. mode:sub(1, 1):upper() .. mode:sub(2) + vim.api.nvim_exec_autocmds("User", { pattern = event, modeline = false }) end end) @@ -179,7 +180,7 @@ function M.sync(opts) clean:wait(function() install:wait(function() update:wait(function() - vim.cmd([[do User LazySync]]) + vim.api.nvim_exec_autocmds("User", { pattern = "LazySync", modeline = false }) end) end) end) @@ -211,7 +212,7 @@ function M.clear(plugins) end, plugin._.tasks) end end - vim.cmd([[do User LazyRender]]) + vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false }) end return M diff --git a/lua/lazy/manage/reloader.lua b/lua/lazy/manage/reloader.lua index 5f9a74b..7d30d3d 100644 --- a/lua/lazy/manage/reloader.lua +++ b/lua/lazy/manage/reloader.lua @@ -83,8 +83,8 @@ function M.check(start) Util.warn(lines) end Plugin.load() - vim.cmd([[do User LazyRender]]) - vim.cmd([[do User LazyReload]]) + vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false }) + vim.api.nvim_exec_autocmds("User", { pattern = "LazyReload", modeline = false }) end) end end diff --git a/lua/lazy/manage/task/init.lua b/lua/lazy/manage/task/init.lua index 92596e3..a68c7d7 100644 --- a/lua/lazy/manage/task/init.lua +++ b/lua/lazy/manage/task/init.lua @@ -85,7 +85,7 @@ function Task:_check() if self._opts.on_done then self._opts.on_done(self) end - vim.cmd("do User LazyRender") + vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false }) vim.api.nvim_exec_autocmds("User", { pattern = "LazyPlugin" .. self.name:sub(1, 1):upper() .. self.name:sub(2), data = { plugin = self.plugin.name }, @@ -131,7 +131,7 @@ function Task:spawn(cmd, opts) if on_line then pcall(on_line, line) end - vim.cmd("do User LazyRender") + vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false }) end ---@param output string diff --git a/lua/lazy/stats.lua b/lua/lazy/stats.lua index facc9dc..a2ccdd8 100644 --- a/lua/lazy/stats.lua +++ b/lua/lazy/stats.lua @@ -21,7 +21,7 @@ M.C = nil function M.on_ui_enter() M._stats.startuptime = M.track("UIEnter") - vim.cmd([[do User LazyVimStarted]]) + vim.api.nvim_exec_autocmds("User", { pattern = "LazyVimStarted", modeline = false }) end function M.track(event) diff --git a/lua/lazy/view/float.lua b/lua/lazy/view/float.lua index d6e3c39..821121b 100644 --- a/lua/lazy/view/float.lua +++ b/lua/lazy/view/float.lua @@ -127,7 +127,7 @@ function M:mount() config.style = self.opts.style ~= "" and self.opts.style or nil vim.api.nvim_win_set_config(self.win, config) opts() - vim.cmd([[do User LazyFloatResized]]) + vim.api.nvim_exec_autocmds("User", { pattern = "LazyFloatResized", modeline = false }) end, }) end