fix: catch errors setting up rtp when plugin not installed

I was getting E5108 .ometimes when a plugin that loads on `start` wasn't
installed. That interrupted Lazy's load, preventing me from then using
it to install the missing plugin.
On Windows it happened every time, on Linux it was about every 2nd time.
This commit is contained in:
bluedrink9 2023-11-23 07:29:05 +13:00
commit 7812d81cd9

View file

@ -472,7 +472,18 @@ function M.add_to_rtp(plugin)
table.insert(rtp, idx_after or (#rtp + 1), after)
end
local ok, result = pcall(function()
vim.opt.rtp = rtp
end)
if not ok then
-- Often gets E5108 when plugins aren't installed, but it's
-- inconsistent.
vim.notify(
"Unable to add rtp for " .. plugin.name .. ". Error message: " .. result,
vim.log.levels.WARN,
{ title = "lazy.nvim" }
)
end
end
function M.source(path)