From d7bc9ce11a5d70d9305f8a610f6c5a674c772faf Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 23 Jun 2024 17:48:10 +0200 Subject: [PATCH] feat(meta): check for dir changes for plugins already added to the rtp --- lua/lazy/core/meta.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/lazy/core/meta.lua b/lua/lazy/core/meta.lua index 35006d7..0deeb89 100644 --- a/lua/lazy/core/meta.lua +++ b/lua/lazy/core/meta.lua @@ -66,6 +66,17 @@ function M:add(plugin) table.insert(meta._.frags, fragment.id) + if meta._ and meta._.rtp_loaded then + local old_dir = meta.dir + self:_rebuild(meta.name) + local new_dir = meta.dir + if old_dir ~= new_dir then + local msg = "Plugin `" .. meta.name .. "` changed `dir`:\n- from: `" .. old_dir .. "`\n- to: `" .. new_dir .. "`" + msg = msg .. "\n\nThis plugin was already partially loaded, so things may break.\nPlease fix your config." + self.spec:error(msg) + end + end + if plugin.name then -- handle renames if meta.name ~= plugin.name then