mirror of https://github.com/folke/lazy.nvim.git
refactor: Loader.source_runtime
This commit is contained in:
parent
fc0a10150f
commit
39c7e21c5f
|
@ -70,18 +70,18 @@ end
|
||||||
function M.packadd(plugin, load_start)
|
function M.packadd(plugin, load_start)
|
||||||
if plugin.opt then
|
if plugin.opt then
|
||||||
vim.cmd.packadd(plugin.name)
|
vim.cmd.packadd(plugin.name)
|
||||||
M.source_plugin_files(plugin, true)
|
M.source_runtime(plugin, "/after/plugin")
|
||||||
elseif load_start then
|
elseif load_start then
|
||||||
vim.opt.runtimepath:append(plugin.dir)
|
vim.opt.runtimepath:append(plugin.dir)
|
||||||
M.source_plugin_files(plugin)
|
M.source_runtime(plugin, "/plugin")
|
||||||
M.source_plugin_files(plugin, true)
|
M.source_runtime(plugin, "/after/plugin")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
---@param after? boolean
|
---@param dir? string
|
||||||
function M.source_plugin_files(plugin, after)
|
function M.source_runtime(plugin, dir)
|
||||||
Util.walk(plugin.dir .. (after and "/after" or "") .. "/plugin", function(path, _, t)
|
Util.walk(plugin.dir .. dir, function(path, _, t)
|
||||||
local ext = path:sub(-3)
|
local ext = path:sub(-3)
|
||||||
if t == "file" and (ext == "lua" or ext == "vim") then
|
if t == "file" and (ext == "lua" or ext == "vim") then
|
||||||
vim.cmd("silent source " .. path)
|
vim.cmd("silent source " .. path)
|
||||||
|
|
Loading…
Reference in New Issue