Skip to content

Commit b73312a

Browse files
committed
fix: use vim.api.nvim_exec_autocmds instead of vim.cmd[[do]] to prevent weird vim.notify behavior
1 parent 81017b9 commit b73312a

File tree

8 files changed

+15
-14
lines changed

8 files changed

+15
-14
lines changed

lua/lazy/core/loader.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function M._load(plugin, reason, opts)
227227
plugin._.loaded.time = Util.track().time
228228
table.remove(M.loading)
229229
vim.schedule(function()
230-
vim.cmd("do User LazyRender")
230+
vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
231231
end)
232232
end
233233

lua/lazy/core/util.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function M.very_lazy()
143143
local function _load()
144144
vim.schedule(function()
145145
vim.g.did_very_lazy = true
146-
vim.cmd("do User VeryLazy")
146+
vim.api.nvim_exec_autocmds("User", { pattern = "VeryLazy", modeline = false })
147147
end)
148148
end
149149

lua/lazy/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function M.setup(spec, opts)
6464
Loader.startup()
6565

6666
-- all done!
67-
vim.cmd("do User LazyDone")
67+
vim.api.nvim_exec_autocmds("User", { pattern = "LazyDone", modeline = false })
6868
require("lazy.stats").track("LazyDone")
6969
end
7070

lua/lazy/manage/init.lua

+6-5
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ function M.run(ropts, opts)
4242
local runner = Runner.new(ropts)
4343
runner:start()
4444

45-
vim.cmd([[do User LazyRender]])
45+
vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
4646

4747
-- wait for post-install to finish
4848
runner:wait(function()
49-
vim.cmd([[do User LazyRender]])
49+
vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
5050
Plugin.update_state()
5151
require("lazy.manage.checker").fast_check({ report = false })
5252
local mode = opts.mode
5353
if mode then
54-
vim.cmd("do User Lazy" .. mode:sub(1, 1):upper() .. mode:sub(2))
54+
local event = "Lazy" .. mode:sub(1, 1):upper() .. mode:sub(2)
55+
vim.api.nvim_exec_autocmds("User", { pattern = event, modeline = false })
5556
end
5657
end)
5758

@@ -179,7 +180,7 @@ function M.sync(opts)
179180
clean:wait(function()
180181
install:wait(function()
181182
update:wait(function()
182-
vim.cmd([[do User LazySync]])
183+
vim.api.nvim_exec_autocmds("User", { pattern = "LazySync", modeline = false })
183184
end)
184185
end)
185186
end)
@@ -211,7 +212,7 @@ function M.clear(plugins)
211212
end, plugin._.tasks)
212213
end
213214
end
214-
vim.cmd([[do User LazyRender]])
215+
vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
215216
end
216217

217218
return M

lua/lazy/manage/reloader.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ function M.check(start)
8383
Util.warn(lines)
8484
end
8585
Plugin.load()
86-
vim.cmd([[do User LazyRender]])
87-
vim.cmd([[do User LazyReload]])
86+
vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
87+
vim.api.nvim_exec_autocmds("User", { pattern = "LazyReload", modeline = false })
8888
end)
8989
end
9090
end

lua/lazy/manage/task/init.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function Task:_check()
8585
if self._opts.on_done then
8686
self._opts.on_done(self)
8787
end
88-
vim.cmd("do User LazyRender")
88+
vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
8989
vim.api.nvim_exec_autocmds("User", {
9090
pattern = "LazyPlugin" .. self.name:sub(1, 1):upper() .. self.name:sub(2),
9191
data = { plugin = self.plugin.name },
@@ -131,7 +131,7 @@ function Task:spawn(cmd, opts)
131131
if on_line then
132132
pcall(on_line, line)
133133
end
134-
vim.cmd("do User LazyRender")
134+
vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
135135
end
136136

137137
---@param output string

lua/lazy/stats.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ M.C = nil
2121

2222
function M.on_ui_enter()
2323
M._stats.startuptime = M.track("UIEnter")
24-
vim.cmd([[do User LazyVimStarted]])
24+
vim.api.nvim_exec_autocmds("User", { pattern = "LazyVimStarted", modeline = false })
2525
end
2626

2727
function M.track(event)

lua/lazy/view/float.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function M:mount()
127127
config.style = self.opts.style ~= "" and self.opts.style or nil
128128
vim.api.nvim_win_set_config(self.win, config)
129129
opts()
130-
vim.cmd([[do User LazyFloatResized]])
130+
vim.api.nvim_exec_autocmds("User", { pattern = "LazyFloatResized", modeline = false })
131131
end,
132132
})
133133
end

0 commit comments

Comments
 (0)