Skip to content

Commit

Permalink
feat(plugin): show error for local plugins that don't exist. Fixes #1773
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 5, 2024
1 parent 56ead98 commit 9570a5a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions lua/lazy/core/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ function M.update_state()
else
plugin._.is_local = true
plugin._.installed = true -- local plugins are managed by the user
plugin._.installed = vim.fn.isdirectory(plugin.dir) == 1
end
end

Expand Down
3 changes: 3 additions & 0 deletions lua/lazy/manage/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function M.install(opts)
opts = M.opts(opts, { mode = "install" })
return M.run({
pipeline = {
"plugin.exists",
"git.clone",
{ "git.checkout", lockfile = opts.lockfile },
"plugin.docs",
Expand Down Expand Up @@ -108,6 +109,7 @@ function M.update(opts)
opts = M.opts(opts, { mode = "update" })
return M.run({
pipeline = {
"plugin.exists",
"git.origin",
"git.branch",
"git.fetch",
Expand Down Expand Up @@ -147,6 +149,7 @@ function M.check(opts)
opts = opts or {}
return M.run({
pipeline = {
"plugin.exists",
{ "git.origin", check = true },
"git.fetch",
"git.status",
Expand Down
11 changes: 11 additions & 0 deletions lua/lazy/manage/task/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,15 @@ M.docs = {
end,
}

M.exists = {
skip = function(plugin)
return not plugin._.is_local
end,
run = function(self)
if not Util.file_exists(self.plugin.dir) then
self:error("Local plugin does not exist at `" .. self.plugin.dir .. "`")
end
end,
}

return M

0 comments on commit 9570a5a

Please sign in to comment.