diff --git a/lua/dep.lua b/lua/dep.lua index d5c1d1b..2a90ad1 100644 --- a/lua/dep.lua +++ b/lua/dep.lua @@ -42,12 +42,10 @@ function M.registertree(speclist, overrides) disable = over.disable or spec.disable } - local ok = packager:new(spec, overrides) - - -- if erroring print out the spec and the error - if not ok then - error(string.format("(spec=%s)", vim.inspect(spec))) - end + -- 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. + packager:new(spec, overrides) end end diff --git a/lua/dep/package.lua b/lua/dep/package.lua index 1ee712c..9112cbc 100644 --- a/lua/dep/package.lua +++ b/lua/dep/package.lua @@ -55,6 +55,17 @@ local root ---@type package[] local packages = {} +--- check if a string seems to be a url +---@param url string the "url" to check +---@return boolean is_url +local function is_url(url) + if url:sub(1, 8) == "https://" or + url:sub(1, 7) == "http://" then + return true + end + return false +end + --- check a spec to see if it's correct ---@param spec spec|string the specification to check ---@return spec|false spec if the spec is ok or false @@ -117,6 +128,10 @@ local function check_spec(spec) if type(spec.url) ~= "string" then logger:log("spec", "spec.url must be a string in %s", spec[1]) return false + elseif not is_url(spec.url) then -- more strict checking on urls + logger:log("spec", "spec.url must be a properly formatted url in %s", + spec[1]) + return false end end @@ -124,6 +139,9 @@ local function check_spec(spec) if type(spec.path) ~= "string" then logger:log("spec", "spec.path must be a string in %s", spec[1]) return false + elseif not vim.fn.isdirectory(spec.path) then + logger:log("spec", "spec.path must be a valid directory in %s", spec[1]) + return false end end