fix(ui): use actual handler values for rendering plugin handlers

This commit is contained in:
Folke Lemaitre 2023-10-11 14:25:10 +02:00
parent b65d308662
commit 99ee284739
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 22 additions and 16 deletions

View File

@ -5,11 +5,6 @@ local Loader = require("lazy.core.loader")
local M = {} local M = {}
M.extends = Event M.extends = Event
---@param value string
function M:_event(value)
return "FileType " .. value
end
---@param plugin LazyPlugin ---@param plugin LazyPlugin
function M:add(plugin) function M:add(plugin)
self.super.add(self, plugin) self.super.add(self, plugin)
@ -18,4 +13,12 @@ function M:add(plugin)
end end
end end
function M:parse(value)
return {
id = value,
event = "FileType",
pattern = value,
}
end
return M return M

View File

@ -319,17 +319,13 @@ function M:reason(reason, opts)
end end
for _, key in ipairs(keys) do for _, key in ipairs(keys) do
local value = reason[key] local value = reason[key]
if type(key) == "number" then local skip = type(key) == "number" or key == "time"
-- elseif key == "require" then if not skip then
elseif key ~= "time" then
if first then if first then
first = false first = false
else else
self:append(" ") self:append(" ")
end end
if key == "event" then
value = value:match("User (.*)") or value
end
if key == "keys" then if key == "keys" then
value = type(value) == "string" and value or value.lhs or value[1] value = type(value) == "string" and value or value.lhs or value[1]
end end
@ -414,11 +410,18 @@ function M:plugin(plugin)
if plugin._.kind ~= "disabled" then if plugin._.kind ~= "disabled" then
for handler in pairs(Handler.types) do for handler in pairs(Handler.types) do
if plugin[handler] then if plugin[handler] then
local trigger = {} local values = Handler.handlers[handler]:values(plugin)
for _, value in ipairs(plugin[handler]) do values = vim.tbl_map(function(value)
table.insert(trigger, type(value) == "table" and value[1] or value) if handler == "ft" or handler == "event" then
---@cast value LazyEvent
return value.id
elseif handler == "keys" then
---@cast value LazyKeys
return value.lhs .. (value.mode == "n" and "" or " (" .. value.mode .. ")")
end end
reason[handler] = table.concat(trigger, " ") return value
end, vim.tbl_values(values))
reason[handler] = table.concat(values, " ")
end end
end end
end end