From 60e96b478a5374ad1829a505549e3170332d1013 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 2 Jan 2023 15:04:32 +0100 Subject: [PATCH] fix(loader): always load init.lua in plugin mods --- lua/lazy/core/cache.lua | 2 +- lua/lazy/core/util.lua | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua index 10c3848..f244f84 100644 --- a/lua/lazy/core/cache.lua +++ b/lua/lazy/core/cache.lua @@ -271,7 +271,7 @@ function M.find_dir(modname) local modpath = M.find(modname, { patterns = { "" } }) if modpath then local root = modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "") - return root, (root ~= modpath and modpath or nil) + return root, modpath end end diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua index b6996f2..e39d3d8 100644 --- a/lua/lazy/core/util.lua +++ b/lua/lazy/core/util.lua @@ -200,12 +200,14 @@ function M.lsmod(modname, fn) return end - if modpath and vim.loop.fs_stat(modpath) then + if modpath and not modpath:find("/init%.lua$") and vim.loop.fs_stat(modpath) then fn(modname, modpath) end M.ls(root, function(path, name, type) - if name ~= "init.lua" and (type == "file" or type == "link") and name:sub(-4) == ".lua" then + if name == "init.lua" then + fn(modname, path) + elseif (type == "file" or type == "link") and name:sub(-4) == ".lua" then fn(modname .. "." .. name:sub(1, -5), path) elseif type == "directory" and vim.loop.fs_stat(path .. "/init.lua") then fn(modname .. "." .. name, path .. "/init.lua")