Skip to content

Commit

Permalink
fix(loader): always load init.lua in plugin mods
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jan 2, 2023
1 parent 9e90852 commit 60e96b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lua/lazy/core/cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions lua/lazy/core/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 60e96b4

Please sign in to comment.