From 39c7e21c5f611dd0965b609c3828095315d28cf7 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 30 Nov 2022 14:41:20 +0100 Subject: [PATCH] refactor: Loader.source_runtime --- lua/lazy/core/loader.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua index f8be35e..093692c 100644 --- a/lua/lazy/core/loader.lua +++ b/lua/lazy/core/loader.lua @@ -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)