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)
if plugin.opt then
vim.cmd.packadd(plugin.name)
M.source_plugin_files(plugin, true)
M.source_runtime(plugin, "/after/plugin")
elseif load_start then
vim.opt.runtimepath:append(plugin.dir)
M.source_plugin_files(plugin)
M.source_plugin_files(plugin, true)
M.source_runtime(plugin, "/plugin")
M.source_runtime(plugin, "/after/plugin")
end
end
---@param plugin LazyPlugin
---@param after? boolean
function M.source_plugin_files(plugin, after)
Util.walk(plugin.dir .. (after and "/after" or "") .. "/plugin", function(path, _, t)
---@param dir? string
function M.source_runtime(plugin, dir)
Util.walk(plugin.dir .. dir, function(path, _, t)
local ext = path:sub(-3)
if t == "file" and (ext == "lua" or ext == "vim") then
vim.cmd("silent source " .. path)