Skip to content

Commit 9570a5a

Browse files
committed
feat(plugin): show error for local plugins that don't exist. Fixes #1773
1 parent 56ead98 commit 9570a5a

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

lua/lazy/core/plugin.lua

+1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ function M.update_state()
243243
else
244244
plugin._.is_local = true
245245
plugin._.installed = true -- local plugins are managed by the user
246+
plugin._.installed = vim.fn.isdirectory(plugin.dir) == 1
246247
end
247248
end
248249

lua/lazy/manage/init.lua

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function M.install(opts)
8080
opts = M.opts(opts, { mode = "install" })
8181
return M.run({
8282
pipeline = {
83+
"plugin.exists",
8384
"git.clone",
8485
{ "git.checkout", lockfile = opts.lockfile },
8586
"plugin.docs",
@@ -108,6 +109,7 @@ function M.update(opts)
108109
opts = M.opts(opts, { mode = "update" })
109110
return M.run({
110111
pipeline = {
112+
"plugin.exists",
111113
"git.origin",
112114
"git.branch",
113115
"git.fetch",
@@ -147,6 +149,7 @@ function M.check(opts)
147149
opts = opts or {}
148150
return M.run({
149151
pipeline = {
152+
"plugin.exists",
150153
{ "git.origin", check = true },
151154
"git.fetch",
152155
"git.status",

lua/lazy/manage/task/plugin.lua

+11
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,15 @@ M.docs = {
9797
end,
9898
}
9999

100+
M.exists = {
101+
skip = function(plugin)
102+
return not plugin._.is_local
103+
end,
104+
run = function(self)
105+
if not Util.file_exists(self.plugin.dir) then
106+
self:error("Local plugin does not exist at `" .. self.plugin.dir .. "`")
107+
end
108+
end,
109+
}
110+
100111
return M

0 commit comments

Comments
 (0)