mirror of https://github.com/folke/lazy.nvim.git
fix: add after directories to rtp to make after/ftplugin and others work. Fixes #47
This commit is contained in:
parent
b193f96f7b
commit
3606d62918
|
@ -179,7 +179,7 @@ function M.get_rtp()
|
||||||
end
|
end
|
||||||
for _, path in ipairs(vim.api.nvim_list_runtime_paths()) do
|
for _, path in ipairs(vim.api.nvim_list_runtime_paths()) do
|
||||||
path = path:gsub("\\", "/")
|
path = path:gsub("\\", "/")
|
||||||
if not skip[path] then
|
if not skip[path] and not path:find("after/?$") then
|
||||||
M.rtp[#M.rtp + 1] = path
|
M.rtp[#M.rtp + 1] = path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,18 +46,11 @@ end
|
||||||
function M.startup()
|
function M.startup()
|
||||||
Util.track({ start = "startup" })
|
Util.track({ start = "startup" })
|
||||||
|
|
||||||
local rtp = vim.opt.rtp:get()
|
M.source(vim.env.VIMRUNTIME .. "/filetype.lua")
|
||||||
|
|
||||||
Util.track({ start = "filetype" })
|
|
||||||
local ft = vim.env.VIMRUNTIME .. "/filetype.lua"
|
|
||||||
Util.try(function()
|
|
||||||
vim.cmd("silent source " .. ft)
|
|
||||||
end, "Failed to source `" .. ft .. "`")
|
|
||||||
Util.track()
|
|
||||||
|
|
||||||
-- load plugins from rtp, excluding after
|
-- load plugins from rtp, excluding after
|
||||||
Util.track({ start = "rtp plugins" })
|
Util.track({ start = "rtp plugins" })
|
||||||
for _, path in ipairs(rtp) do
|
for _, path in ipairs(vim.opt.rtp:get()) do
|
||||||
if not path:find("after/?$") then
|
if not path:find("after/?$") then
|
||||||
M.packadd(path)
|
M.packadd(path)
|
||||||
end
|
end
|
||||||
|
@ -73,16 +66,9 @@ function M.startup()
|
||||||
end
|
end
|
||||||
Util.track()
|
Util.track()
|
||||||
|
|
||||||
-- load after files
|
-- load after plugins
|
||||||
Util.track({ start = "after" })
|
Util.track({ start = "after" })
|
||||||
-- load after files from plugins
|
for _, path in ipairs(vim.opt.rtp:get()) do
|
||||||
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
|
if path:find("after/?$") then
|
||||||
M.source_runtime(path, "plugin")
|
M.source_runtime(path, "plugin")
|
||||||
end
|
end
|
||||||
|
@ -135,6 +121,10 @@ function M.load(plugins, reason)
|
||||||
Handler.disable(plugin)
|
Handler.disable(plugin)
|
||||||
|
|
||||||
vim.opt.runtimepath:prepend(plugin.dir)
|
vim.opt.runtimepath:prepend(plugin.dir)
|
||||||
|
local after = plugin.dir .. "/after"
|
||||||
|
if vim.loop.fs_stat(after) then
|
||||||
|
vim.opt.runtimepath:append(after)
|
||||||
|
end
|
||||||
|
|
||||||
if plugin.dependencies then
|
if plugin.dependencies then
|
||||||
M.load(plugin.dependencies, {})
|
M.load(plugin.dependencies, {})
|
||||||
|
@ -185,13 +175,17 @@ function M.source_runtime(...)
|
||||||
-- plugin files are sourced alphabetically per directory
|
-- plugin files are sourced alphabetically per directory
|
||||||
table.sort(files)
|
table.sort(files)
|
||||||
for _, path in ipairs(files) do
|
for _, path in ipairs(files) do
|
||||||
|
M.source(path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.source(path)
|
||||||
Util.track({ runtime = path })
|
Util.track({ runtime = path })
|
||||||
Util.try(function()
|
Util.try(function()
|
||||||
vim.cmd("silent source " .. path)
|
vim.cmd("silent source " .. path)
|
||||||
end, "Failed to source `" .. path .. "`")
|
end, "Failed to source `" .. path .. "`")
|
||||||
Util.track()
|
Util.track()
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- This loader is added as the very last one.
|
-- This loader is added as the very last one.
|
||||||
-- This only hits when the modname is not cached and
|
-- This only hits when the modname is not cached and
|
||||||
|
|
Loading…
Reference in New Issue