fix(mini.starter): just do do VimResized for simpler approach

This commit is contained in:
Iordanis Petkakis 2024-05-18 10:52:45 +03:00
parent e2abb1ea4f
commit 5da98c76d8

View file

@ -53,16 +53,7 @@ return {
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
pattern = "MiniStarterOpened", pattern = "MiniStarterOpened",
callback = function() callback = function()
-- INFO: schedule_wrap this because if you are missing a plugin
-- and the Lazy UI opens to install the missing plugin the
-- notification `buf_id in refresh() is not an identifier of valid
-- Starter buffer` shows up again
-- `vim.schedule` also seems to work but prefered `vim.schedule_wrap`
-- because on my understanding it triggers even later than `vim.schedule`
-- just to be on the safe side
vim.schedule_wrap(function()
require("lazy").show() require("lazy").show()
end)
end, end,
}) })
end end
@ -71,13 +62,15 @@ return {
starter.setup(config) starter.setup(config)
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
pattern = "MiniStarterOpened", pattern = "LazyVimStarted",
callback = function() callback = function()
local stats = require("lazy").stats() local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
local pad_footer = string.rep(" ", 8) local pad_footer = string.rep(" ", 8)
starter.config.footer = pad_footer .. "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" starter.config.footer = pad_footer .. "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms"
pcall(starter.refresh) -- INFO: Use `VimResized` to avoid the `buf_id in refresh() is not an identifier of valid Starter buffer`,
-- since `starter.refresh` executes on every `VimResized` see https://github.com/echasnovski/mini.starter/blob/f0c491032dcda485ee740716217cd4d5c25b6014/lua/mini/starter.lua#L352-L353
vim.cmd([[do VimResized]])
end, end,
}) })
end, end,