mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
feat(plugin): allow plugin files only without a main plugin module. Fixes #53
This commit is contained in:
parent
f5734f512f
commit
44f80a7f5d
4 changed files with 23 additions and 16 deletions
|
@ -158,14 +158,28 @@ function M.walk(path, fn)
|
|||
end)
|
||||
end
|
||||
|
||||
---@param modname string
|
||||
---@param root string
|
||||
---@param fn fun(modname:string, modpath:string)
|
||||
function M.lsmod(root, fn)
|
||||
---@overload fun(modname:string, fn: fun(modname:string, modpath:string))
|
||||
function M.lsmod(modname, root, fn)
|
||||
if type(root) == "function" then
|
||||
fn = root
|
||||
root = vim.fn.stdpath("config") .. "/lua"
|
||||
end
|
||||
root = root .. "/" .. modname:gsub("%.", "/")
|
||||
if vim.loop.fs_stat(root .. ".lua") then
|
||||
fn(modname, root .. ".lua")
|
||||
end
|
||||
M.ls(root, function(path, name, type)
|
||||
if type == "file" and name:sub(-4) == ".lua" and name ~= "init.lua" then
|
||||
fn(name:sub(1, -5), path)
|
||||
if type == "file" and name:sub(-4) == ".lua" then
|
||||
if name == "init.lua" then
|
||||
fn(modname, path)
|
||||
else
|
||||
fn(modname .. "." .. name:sub(1, -5), path)
|
||||
end
|
||||
elseif type == "directory" and vim.loop.fs_stat(path .. "/init.lua") then
|
||||
fn(name, path .. "/init.lua")
|
||||
fn(modname .. "." .. name, path .. "/init.lua")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue