Skip to content

Commit

Permalink
fix: use vim.api.nvim_exec_autocmds instead of vim.cmd[[do]] to p…
Browse files Browse the repository at this point in the history
…revent weird `vim.notify` behavior
  • Loading branch information
folke committed Jan 13, 2023
1 parent 81017b9 commit b73312a
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lua/lazy/core/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lua/lazy/core/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lua/lazy/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions lua/lazy/manage/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions lua/lazy/manage/reloader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lua/lazy/manage/task/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lua/lazy/stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lua/lazy/view/float.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b73312a

Please sign in to comment.