Skip to content

Commit

Permalink
fix(install): dont try re-installing failed missing plugins during st…
Browse files Browse the repository at this point in the history
…artup. Fixes #303
  • Loading branch information
folke committed Jan 3, 2023
1 parent 1fd8015 commit c85f929
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
9 changes: 6 additions & 3 deletions lua/lazy/core/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ function M.setup()
-- install missing plugins
if Config.options.install.missing then
Util.track("install")
local count = 0
while M.install_missing() do
count = count + 1
if count > 5 then
break
end
end
Util.track()
end
Expand All @@ -51,7 +56,7 @@ end
-- multiple rounds can happen when importing a spec from a missing plugin
function M.install_missing()
for _, plugin in pairs(Config.plugins) do
if not plugin._.installed then
if not (plugin._.installed or Plugin.has_errors(plugin)) then
for _, colorscheme in ipairs(Config.options.install.colorscheme) do
if pcall(vim.cmd.colorscheme, colorscheme) then
break
Expand All @@ -64,8 +69,6 @@ function M.install_missing()
Cache.indexed[p.dir] = nil
end
end
-- clear plugins. no need to merge in this stage
Config.plugins = {}
-- reload plugins
Plugin.load()
return true
Expand Down
10 changes: 10 additions & 0 deletions lua/lazy/core/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,14 @@ function M.find(path)
end
end

---@param plugin LazyPlugin
function M.has_errors(plugin)
for _, task in ipairs(plugin._.tasks or {}) do
if task.error then
return true
end
end
return false
end

return M
24 changes: 18 additions & 6 deletions lua/lazy/manage/checker.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local Config = require("lazy.core.config")
local Manage = require("lazy.manage")
local Util = require("lazy.util")
local Plugin = require("lazy.core.plugin")
local Git = require("lazy.manage.git")

local M = {}
Expand Down Expand Up @@ -31,13 +32,24 @@ function M.fast_check(opts)
end

function M.check()
Manage.check({
show = false,
concurrency = Config.options.checker.concurrency,
}):wait(function()
M.report()
local errors = false
for _, plugin in pairs(Config.plugins) do
if Plugin.has_errors(plugin) then
errors = true
break
end
end
if errors then
vim.defer_fn(M.check, Config.options.checker.frequency * 1000)
end)
else
Manage.check({
show = false,
concurrency = Config.options.checker.concurrency,
}):wait(function()
M.report()
vim.defer_fn(M.check, Config.options.checker.frequency * 1000)
end)
end
end

---@param notify? boolean
Expand Down

0 comments on commit c85f929

Please sign in to comment.