Skip to content

Commit

Permalink
fix: use initial rtp for rtp plugin after files and use loaded plugin…
Browse files Browse the repository at this point in the history
…s for their after files
  • Loading branch information
folke committed Dec 15, 2022
1 parent 6ca03dc commit 7134417
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions lua/lazy/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function M.setup(spec, opts)
me,
vim.env.VIMRUNTIME,
vim.fn.stdpath("config"),
vim.fn.stdpath("config") .. "/after",
}
end
vim.opt.rtp:append(M.options.readme.root)
Expand Down
37 changes: 22 additions & 15 deletions lua/lazy/core/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,46 @@ end
function M.startup()
Util.track({ start = "startup" })

-- load plugins from rtp
local rtp = vim.opt.rtp:get()

-- load plugins from rtp, excluding after
Util.track({ start = "rtp plugins" })
for _, path in ipairs(vim.opt.rtp:get()) do
for _, path in ipairs(rtp) do
if not path:find("after/?$") then
M.source_runtime(path, "plugin")
M.ftdetect(path)
end
end
Util.track()

-- load start plugin
Util.track({ start = "start" })
for _, plugin in pairs(Config.plugins) do
-- load start plugin
if plugin.lazy == false then
M.load(plugin, { start = "start" })
end
end
Util.track()

-- load after files
Util.track({ start = "after" })
-- load after files from plugins
for _, plugin in pairs(Config.plugins) do
if plugin._.loaded then
M.source_runtime(plugin.dir, "after/plugin")
end
end
-- load after files from rtp plugins
for _, path in ipairs(rtp) do
if path:find("after/?$") then
M.source_runtime(path, "plugin")
end
end
Util.track()

-- run plugin init
Util.track({ start = "init" })
for _, plugin in pairs(Config.plugins) do
-- run plugin init
if plugin.init then
Util.track({ plugin = plugin.name, init = "init" })
Util.try(plugin.init, "Failed to run `init` for **" .. plugin.name .. "**")
Expand All @@ -76,17 +94,6 @@ function M.startup()
end
Util.track()

-- load after files
Util.track({ start = "after" })
for _, path in ipairs(vim.opt.rtp:get()) do
if path:find("after/?$") then
M.source_runtime(path, "plugin")
else
M.source_runtime(path, "after/plugin")
end
end
Util.track()

M.init_done = true
Util.track()
end
Expand Down

0 comments on commit 7134417

Please sign in to comment.