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