fix(util): made Util.lsmod more robust. See #298

This commit is contained in:
Folke Lemaitre 2023-01-03 22:31:18 +01:00
parent f36c7cb0dc
commit 953c2791d8
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 52 additions and 15 deletions

View file

@ -195,13 +195,13 @@ end
---@param fn fun(modname:string, modpath:string)
function M.lsmod(modname, fn)
local Cache = require("lazy.core.cache")
local root, modpath = Cache.find_dir(modname)
local root = Cache.find_root(modname)
if not root then
return
end
if modpath and not modpath:find("/init%.lua$") and vim.loop.fs_stat(modpath) then
fn(modname, modpath)
if vim.loop.fs_stat(root .. ".lua") then
fn(modname, root .. ".lua")
end
M.ls(root, function(path, name, type)