diff --git a/lua/dep/modules/module.lua b/lua/dep/modules/module.lua index a6cd04d..7e6d12e 100644 --- a/lua/dep/modules/module.lua +++ b/lua/dep/modules/module.lua @@ -7,6 +7,7 @@ local packager = require("dep.package") ---@field desc string description of the module ---@field path string path to the module ---@field mod table the module +---@field packages package[] all packages registed from the module local module = {} --- Initialize a module @@ -55,6 +56,9 @@ function module:new(modpath, prefix, overrides) return false end + -- ensure that the module contains the packages that it's created + self.packages = err + return self end diff --git a/lua/dep/package.lua b/lua/dep/package.lua index 7ef768a..e9345f8 100644 --- a/lua/dep/package.lua +++ b/lua/dep/package.lua @@ -452,8 +452,10 @@ end --- recurse over all packages and register them ---@param speclist speclist table of specs ---@param overrides spec? a package spec that is used to override options +---@return package[] packages function package.register_speclist(speclist, overrides) overrides = overrides or {} + local packages_from_speclist = {} -- recurse the packages local over = overrides @@ -468,8 +470,19 @@ function package.register_speclist(speclist, overrides) -- While a package can fail to load we just don't care, it will work itself -- out. The goal is to make sure every plugin that can load does load, not -- keep working plugins from loading because an unrelated one doesn't load. - package:new(spec, over) + local pkg = package:new(spec, over) + if not pkg then + goto continue + end + + -- we store all the packages in a table so that the caller may keep track of + -- their packages, this is not required and therefore the return value may + -- be discarded + table.insert(packages_from_speclist, pkg) + ::continue:: end + + return packages_from_speclist end --- reload the package