feat: lazy setup with either a plugins module, or a plugins spec

This commit is contained in:
Folke Lemaitre 2022-12-01 13:33:55 +01:00
parent f0894be69d
commit af8b8e128e
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
8 changed files with 54 additions and 53 deletions

View file

@ -193,25 +193,14 @@ function M:reason(reason, opts)
---@type string?
local source = reason.source
if source then
---@type string?
local modname = source:match("/lua/(.*)%.lua$")
if modname then
modname = modname:gsub("/", ".")
end
local name = source:match("/([^/]-)/lua")
for _, other in pairs(Config.plugins) do
if (modname and other.modname == modname) or (name and other.name == name) then
if name and other.name == name then
reason.plugin = other.name
reason.source = nil
break
end
end
if reason.source then
reason.source = modname or reason.source
if reason.source == "lua" then
reason.source = Config.options.plugins
end
end
end
local time = " " .. math.floor((reason.time or 0) / 1e6 * 100) / 100 .. "ms"
if not opts.time_right then