Skip to content

Commit 7134417

Browse files
committed
fix: use initial rtp for rtp plugin after files and use loaded plugins for their after files
1 parent 6ca03dc commit 7134417

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

lua/lazy/core/config.lua

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ function M.setup(spec, opts)
119119
me,
120120
vim.env.VIMRUNTIME,
121121
vim.fn.stdpath("config"),
122+
vim.fn.stdpath("config") .. "/after",
122123
}
123124
end
124125
vim.opt.rtp:append(M.options.readme.root)

lua/lazy/core/loader.lua

+22-15
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,46 @@ end
4646
function M.startup()
4747
Util.track({ start = "startup" })
4848

49-
-- load plugins from rtp
49+
local rtp = vim.opt.rtp:get()
50+
51+
-- load plugins from rtp, excluding after
5052
Util.track({ start = "rtp plugins" })
51-
for _, path in ipairs(vim.opt.rtp:get()) do
53+
for _, path in ipairs(rtp) do
5254
if not path:find("after/?$") then
5355
M.source_runtime(path, "plugin")
5456
M.ftdetect(path)
5557
end
5658
end
5759
Util.track()
5860

61+
-- load start plugin
5962
Util.track({ start = "start" })
6063
for _, plugin in pairs(Config.plugins) do
61-
-- load start plugin
6264
if plugin.lazy == false then
6365
M.load(plugin, { start = "start" })
6466
end
6567
end
6668
Util.track()
6769

70+
-- load after files
71+
Util.track({ start = "after" })
72+
-- load after files from plugins
73+
for _, plugin in pairs(Config.plugins) do
74+
if plugin._.loaded then
75+
M.source_runtime(plugin.dir, "after/plugin")
76+
end
77+
end
78+
-- load after files from rtp plugins
79+
for _, path in ipairs(rtp) do
80+
if path:find("after/?$") then
81+
M.source_runtime(path, "plugin")
82+
end
83+
end
84+
Util.track()
85+
86+
-- run plugin init
6887
Util.track({ start = "init" })
6988
for _, plugin in pairs(Config.plugins) do
70-
-- run plugin init
7189
if plugin.init then
7290
Util.track({ plugin = plugin.name, init = "init" })
7391
Util.try(plugin.init, "Failed to run `init` for **" .. plugin.name .. "**")
@@ -76,17 +94,6 @@ function M.startup()
7694
end
7795
Util.track()
7896

79-
-- load after files
80-
Util.track({ start = "after" })
81-
for _, path in ipairs(vim.opt.rtp:get()) do
82-
if path:find("after/?$") then
83-
M.source_runtime(path, "plugin")
84-
else
85-
M.source_runtime(path, "after/plugin")
86-
end
87-
end
88-
Util.track()
89-
9097
M.init_done = true
9198
Util.track()
9299
end

0 commit comments

Comments
 (0)