Skip to content

Commit c85f929

Browse files
committed
fix(install): dont try re-installing failed missing plugins during startup. Fixes #303
1 parent 1fd8015 commit c85f929

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

lua/lazy/core/loader.lua

+6-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ function M.setup()
3333
-- install missing plugins
3434
if Config.options.install.missing then
3535
Util.track("install")
36+
local count = 0
3637
while M.install_missing() do
38+
count = count + 1
39+
if count > 5 then
40+
break
41+
end
3742
end
3843
Util.track()
3944
end
@@ -51,7 +56,7 @@ end
5156
-- multiple rounds can happen when importing a spec from a missing plugin
5257
function M.install_missing()
5358
for _, plugin in pairs(Config.plugins) do
54-
if not plugin._.installed then
59+
if not (plugin._.installed or Plugin.has_errors(plugin)) then
5560
for _, colorscheme in ipairs(Config.options.install.colorscheme) do
5661
if pcall(vim.cmd.colorscheme, colorscheme) then
5762
break
@@ -64,8 +69,6 @@ function M.install_missing()
6469
Cache.indexed[p.dir] = nil
6570
end
6671
end
67-
-- clear plugins. no need to merge in this stage
68-
Config.plugins = {}
6972
-- reload plugins
7073
Plugin.load()
7174
return true

lua/lazy/core/plugin.lua

+10
Original file line numberDiff line numberDiff line change
@@ -326,4 +326,14 @@ function M.find(path)
326326
end
327327
end
328328

329+
---@param plugin LazyPlugin
330+
function M.has_errors(plugin)
331+
for _, task in ipairs(plugin._.tasks or {}) do
332+
if task.error then
333+
return true
334+
end
335+
end
336+
return false
337+
end
338+
329339
return M

lua/lazy/manage/checker.lua

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local Config = require("lazy.core.config")
22
local Manage = require("lazy.manage")
33
local Util = require("lazy.util")
4+
local Plugin = require("lazy.core.plugin")
45
local Git = require("lazy.manage.git")
56

67
local M = {}
@@ -31,13 +32,24 @@ function M.fast_check(opts)
3132
end
3233

3334
function M.check()
34-
Manage.check({
35-
show = false,
36-
concurrency = Config.options.checker.concurrency,
37-
}):wait(function()
38-
M.report()
35+
local errors = false
36+
for _, plugin in pairs(Config.plugins) do
37+
if Plugin.has_errors(plugin) then
38+
errors = true
39+
break
40+
end
41+
end
42+
if errors then
3943
vim.defer_fn(M.check, Config.options.checker.frequency * 1000)
40-
end)
44+
else
45+
Manage.check({
46+
show = false,
47+
concurrency = Config.options.checker.concurrency,
48+
}):wait(function()
49+
M.report()
50+
vim.defer_fn(M.check, Config.options.checker.frequency * 1000)
51+
end)
52+
end
4153
end
4254

4355
---@param notify? boolean

0 commit comments

Comments
 (0)