mirror of https://github.com/folke/lazy.nvim.git
fix: use initial rtp for rtp plugin after files and use loaded plugins for their after files
This commit is contained in:
parent
6ca03dcd1a
commit
7134417e89
|
@ -119,6 +119,7 @@ function M.setup(spec, opts)
|
||||||
me,
|
me,
|
||||||
vim.env.VIMRUNTIME,
|
vim.env.VIMRUNTIME,
|
||||||
vim.fn.stdpath("config"),
|
vim.fn.stdpath("config"),
|
||||||
|
vim.fn.stdpath("config") .. "/after",
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
vim.opt.rtp:append(M.options.readme.root)
|
vim.opt.rtp:append(M.options.readme.root)
|
||||||
|
|
|
@ -46,9 +46,11 @@ end
|
||||||
function M.startup()
|
function M.startup()
|
||||||
Util.track({ start = "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" })
|
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
|
if not path:find("after/?$") then
|
||||||
M.source_runtime(path, "plugin")
|
M.source_runtime(path, "plugin")
|
||||||
M.ftdetect(path)
|
M.ftdetect(path)
|
||||||
|
@ -56,33 +58,38 @@ function M.startup()
|
||||||
end
|
end
|
||||||
Util.track()
|
Util.track()
|
||||||
|
|
||||||
|
-- load start plugin
|
||||||
Util.track({ start = "start" })
|
Util.track({ start = "start" })
|
||||||
for _, plugin in pairs(Config.plugins) do
|
for _, plugin in pairs(Config.plugins) do
|
||||||
-- load start plugin
|
|
||||||
if plugin.lazy == false then
|
if plugin.lazy == false then
|
||||||
M.load(plugin, { start = "start" })
|
M.load(plugin, { start = "start" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Util.track()
|
Util.track()
|
||||||
|
|
||||||
Util.track({ start = "init" })
|
-- load after files
|
||||||
|
Util.track({ start = "after" })
|
||||||
|
-- load after files from plugins
|
||||||
for _, plugin in pairs(Config.plugins) do
|
for _, plugin in pairs(Config.plugins) do
|
||||||
-- run plugin init
|
if plugin._.loaded then
|
||||||
if plugin.init then
|
M.source_runtime(plugin.dir, "after/plugin")
|
||||||
Util.track({ plugin = plugin.name, init = "init" })
|
end
|
||||||
Util.try(plugin.init, "Failed to run `init` for **" .. plugin.name .. "**")
|
end
|
||||||
Util.track()
|
-- load after files from rtp plugins
|
||||||
|
for _, path in ipairs(rtp) do
|
||||||
|
if path:find("after/?$") then
|
||||||
|
M.source_runtime(path, "plugin")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Util.track()
|
Util.track()
|
||||||
|
|
||||||
-- load after files
|
-- run plugin init
|
||||||
Util.track({ start = "after" })
|
Util.track({ start = "init" })
|
||||||
for _, path in ipairs(vim.opt.rtp:get()) do
|
for _, plugin in pairs(Config.plugins) do
|
||||||
if path:find("after/?$") then
|
if plugin.init then
|
||||||
M.source_runtime(path, "plugin")
|
Util.track({ plugin = plugin.name, init = "init" })
|
||||||
else
|
Util.try(plugin.init, "Failed to run `init` for **" .. plugin.name .. "**")
|
||||||
M.source_runtime(path, "after/plugin")
|
Util.track()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Util.track()
|
Util.track()
|
||||||
|
|
Loading…
Reference in New Issue