Abort clean when a plugin spec fails to parse

An unparseable entry dropped out of the wanted set, so clean deleted the
directory and lock entry of a plugin the user still has configured.

Add tests/init_spec.lua covering setup, sync, clean and list.
This commit is contained in:
2026-09-08 23:32:04 +10:00
parent 46517953e5
commit 3190b30e97
3 changed files with 418 additions and 2 deletions
+10 -1
View File
@@ -119,7 +119,16 @@ function M.sync(opts)
end
function M.clean()
local specs = spec_mod.parse_all(M.config.plugins)
local specs, errors = spec_mod.parse_all(M.config.plugins)
for _, err in ipairs(errors) do
notify(err, vim.log.levels.ERROR)
end
-- An unparseable entry still names a plugin the user wants, so the set of
-- wanted names is incomplete; deleting from it would remove a live install.
if #errors > 0 then
return notify('clean aborted, no plugin spec may be in error', vim.log.levels.WARN)
end
local wanted = {}
for _, spec in ipairs(specs) do
wanted[spec.name] = true