Skip to content

Commit ee2ca39

Browse files
committed
feat(meta): check for dir changes for plugins already added to the rtp
1 parent 05e31ad commit ee2ca39

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lua/lazy/core/meta.lua

+11
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ function M:add(plugin)
6666

6767
table.insert(meta._.frags, fragment.id)
6868

69+
if meta._ and meta._.rtp_loaded then
70+
local old_dir = meta.dir
71+
self:_rebuild(meta.name)
72+
local new_dir = meta.dir
73+
if old_dir ~= new_dir then
74+
local msg = "Plugin `" .. meta.name .. "` changed `dir`:\n- from: `" .. old_dir .. "`\n- to: `" .. new_dir .. "`"
75+
msg = msg .. "\n\nThis plugin was already partially loaded, so things may break.\nPlease fix your config."
76+
self.spec:error(msg)
77+
end
78+
end
79+
6980
if plugin.name then
7081
-- handle renames
7182
if meta.name ~= plugin.name then

0 commit comments

Comments
 (0)