mirror of https://github.com/folke/lazy.nvim.git
fix: support adding top-level lua directories
This commit is contained in:
parent
fca984b18c
commit
72889623af
|
@ -58,11 +58,11 @@ local function _add_module(dir, modname)
|
||||||
for _, entry in ipairs(entries) do
|
for _, entry in ipairs(entries) do
|
||||||
local path = dir .. "/" .. entry.name
|
local path = dir .. "/" .. entry.name
|
||||||
if entry.type == "directory" then
|
if entry.type == "directory" then
|
||||||
_add_module(path, modname .. "." .. entry.name)
|
_add_module(path, modname and (modname .. "." .. entry.name) or entry.name)
|
||||||
else
|
else
|
||||||
local childname = entry.name:match("^(.*)%.lua$")
|
local childname = entry.name:match("^(.*)%.lua$")
|
||||||
if childname then
|
if childname then
|
||||||
local child = entry.name == "init.lua" and modname or (modname .. "." .. childname)
|
local child = entry.name == "init.lua" and modname or modname and (modname .. "." .. childname) or childname
|
||||||
if child then
|
if child then
|
||||||
M.add(child, path)
|
M.add(child, path)
|
||||||
end
|
end
|
||||||
|
@ -76,6 +76,9 @@ local function _add_module(dir, modname)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.add_module(path)
|
function M.add_module(path)
|
||||||
|
if path:find("/lua/?$") then
|
||||||
|
return _add_module(path)
|
||||||
|
end
|
||||||
---@type string
|
---@type string
|
||||||
local modname = path:match("/lua/(.*)/?")
|
local modname = path:match("/lua/(.*)/?")
|
||||||
assert(modname)
|
assert(modname)
|
||||||
|
|
|
@ -39,6 +39,10 @@ function M.setup(opts)
|
||||||
-- rebuild state
|
-- rebuild state
|
||||||
local Plugin = require("lazy.plugin")
|
local Plugin = require("lazy.plugin")
|
||||||
Module.add_module(vim.fn.stdpath("config") .. "/lua/" .. Config.options.plugins:gsub("%.", "/"))
|
Module.add_module(vim.fn.stdpath("config") .. "/lua/" .. Config.options.plugins:gsub("%.", "/"))
|
||||||
|
-- Module.add_module(vim.fn.stdpath("config") .. "/lua")
|
||||||
|
-- Module.add_module(Config.options.package_path .. "/start/tokyonight.nvim/lua")
|
||||||
|
-- Module.add_module(Config.options.package_path .. "/opt/nvim-cmp/lua")
|
||||||
|
-- Module.add_module(Config.options.package_path .. "/opt/cmp-buffer/lua")
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
vim.notify("Reloading")
|
vim.notify("Reloading")
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue