refactor(cache): refactor for upstreaming to vim.loader

This commit is contained in:
Folke Lemaitre 2023-03-15 15:10:44 +01:00
parent e27c9df5fe
commit 6b55862d2d
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
4 changed files with 144 additions and 97 deletions

View file

@ -241,13 +241,13 @@ function M.get_unloaded_rtp(modname)
end
function M.find_root(modname)
local modpath = require("lazy.core.cache").find(modname, {
local ret = require("lazy.core.cache").find(modname, {
rtp = true,
paths = M.get_unloaded_rtp(modname),
patterns = { "", ".lua" },
})
if modpath then
local root = modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "")
})[1]
if ret then
local root = ret.modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "")
return root
end
end