refactor: Loader.source_runtime

This commit is contained in:
Folke Lemaitre 2022-11-30 14:41:20 +01:00
parent fc0a10150f
commit 39c7e21c5f
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 6 additions and 6 deletions

View File

@ -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)