fix(loader): always load init.lua in plugin mods

This commit is contained in:
Folke Lemaitre 2023-01-02 15:04:32 +01:00
parent 9e90852a47
commit 60e96b478a
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 5 additions and 3 deletions

View File

@ -271,7 +271,7 @@ function M.find_dir(modname)
local modpath = M.find(modname, { patterns = { "" } }) local modpath = M.find(modname, { patterns = { "" } })
if modpath then if modpath then
local root = modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "") local root = modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "")
return root, (root ~= modpath and modpath or nil) return root, modpath
end end
end end

View File

@ -200,12 +200,14 @@ function M.lsmod(modname, fn)
return return
end 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) fn(modname, modpath)
end end
M.ls(root, function(path, name, type) 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) fn(modname .. "." .. name:sub(1, -5), path)
elseif type == "directory" and vim.loop.fs_stat(path .. "/init.lua") then elseif type == "directory" and vim.loop.fs_stat(path .. "/init.lua") then
fn(modname .. "." .. name, path .. "/init.lua") fn(modname .. "." .. name, path .. "/init.lua")