fix: use `vim.api.nvim_exec_autocmds` instead of `vim.cmd[[do]]` to prevent weird `vim.notify` behavior

This commit is contained in:
Folke Lemaitre 2023-01-13 09:00:15 +01:00
parent 81017b99e7
commit b73312aa32
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
8 changed files with 15 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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