From 7812d81cd9e2adc0c90ee6814938486c573f5c64 Mon Sep 17 00:00:00 2001 From: bluedrink9 Date: Thu, 23 Nov 2023 07:29:05 +1300 Subject: [PATCH] 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. --- lua/lazy/core/loader.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua index 0dc9e9f..2b0961b 100644 --- a/lua/lazy/core/loader.lua +++ b/lua/lazy/core/loader.lua @@ -472,7 +472,18 @@ function M.add_to_rtp(plugin) table.insert(rtp, idx_after or (#rtp + 1), after) end - vim.opt.rtp = rtp + 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)