Compare commits

..

5 Commits

7 changed files with 32 additions and 10 deletions

View File

@ -57,6 +57,7 @@ function M.synctree(tree, cb)
end end
-- basically the main function of our program -- basically the main function of our program
---@param opts speclist
return function(opts) return function(opts)
logger.pipe = logger:setup() logger.pipe = logger:setup()
bench:setup() bench:setup()

View File

@ -23,14 +23,13 @@ function modules:setup(speclist, overrides)
-- loop through all modules and initialize them -- loop through all modules and initialize them
for _, modpath in ipairs(speclist.modules) do for _, modpath in ipairs(speclist.modules) do
local mod = module.new( local mod = module.new(nil, modpath, speclist.modules.prefix, overrides)
nil, if not mod then
modpath, goto continue
speclist.modules.prefix, end
overrides
)
table.insert(o.modules, mod) table.insert(o.modules, mod)
::continue::
end end
return self return self

View File

@ -1,3 +1,4 @@
local logger = require('dep.log')
local spec_man = require("dep.spec") local spec_man = require("dep.spec")
local packager = require("dep.package") local packager = require("dep.package")
@ -6,6 +7,7 @@ local packager = require("dep.package")
---@field desc string description of the module ---@field desc string description of the module
---@field path string path to the module ---@field path string path to the module
---@field mod table the module ---@field mod table the module
---@field packages package[] all packages registed from the module
local module = {} local module = {}
--- Initialize a module --- Initialize a module
@ -36,6 +38,7 @@ function module:new(modpath, prefix, overrides)
o.name = modpath o.name = modpath
ok, o.mod = pcall(require, o.path) ok, o.mod = pcall(require, o.path)
if not ok then if not ok then
logger:log("error", "failed to load module: %s", vim.inspect(o.mod))
return false return false
end end
end end
@ -49,9 +52,13 @@ function module:new(modpath, prefix, overrides)
ok, err = pcall(packager.register_speclist, o.mod, overrides) ok, err = pcall(packager.register_speclist, o.mod, overrides)
if not ok then if not ok then
error(string.format("%s <- %s", err, o.name)) logger:log("error", "%s <- %s", err, o.name)
return false
end end
-- ensure that the module contains the packages that it's created
self.packages = err
return self return self
end end

View File

@ -299,7 +299,7 @@ function package:ensureadded(force)
self.lazied = true self.lazied = true
for _, load_cond in pairs(self.lazy_load) do for _, load_cond in pairs(self.lazy_load) do
-- configure the lazy loader for the user -- configure the lazy loader for the user
local l = require('lazy.utils'):new() local l = require('dep.lazy.utils'):new()
if l == true then if l == true then
logger:log("lazy", "failed to get lazy utils") logger:log("lazy", "failed to get lazy utils")
return false return false
@ -452,8 +452,10 @@ end
--- recurse over all packages and register them --- recurse over all packages and register them
---@param speclist speclist table of specs ---@param speclist speclist table of specs
---@param overrides spec? a package spec that is used to override options ---@param overrides spec? a package spec that is used to override options
---@return package[] packages
function package.register_speclist(speclist, overrides) function package.register_speclist(speclist, overrides)
overrides = overrides or {} overrides = overrides or {}
local packages_from_speclist = {}
-- recurse the packages -- recurse the packages
local over = overrides 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 -- 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 -- 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. -- 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 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 end
--- reload the package --- reload the package

View File

@ -5,7 +5,9 @@ local logger = require("dep.log")
---@field [integer] string list of all modules to load ---@field [integer] string list of all modules to load
---@class speclist ---@class speclist
---@field modules specmodules a list of modules ---@field modules specmodules? a list of modules
---@field base_dir string? the base directory for all plugins
---@field sync ("new"|"always")? when to sync (defaults to new)
---@field [integer] spec a spec ---@field [integer] spec a spec
---@class spec ---@class spec