fix(ui): show first tag for each help doc in details

This commit is contained in:
Folke Lemaitre 2022-12-17 10:38:42 +01:00
parent 97366711be
commit 6f728e698d
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 24 additions and 12 deletions

View File

@ -218,8 +218,8 @@ function M:reason(reason, opts)
local time = reason.time and (" " .. math.floor(reason.time / 1e6 * 100) / 100 .. "ms") local time = reason.time and (" " .. math.floor(reason.time / 1e6 * 100) / 100 .. "ms")
if time and not opts.time_right then if time and not opts.time_right then
self:append(time, "Bold") self:append(time, "Bold")
end
self:append(" ") self:append(" ")
end
-- self:append(" (", "Conceal") -- self:append(" (", "Conceal")
local first = true local first = true
local keys = vim.tbl_keys(reason) local keys = vim.tbl_keys(reason)
@ -387,10 +387,13 @@ function M:details(plugin)
if Util.file_exists(plugin.dir .. "/README.md") then if Util.file_exists(plugin.dir .. "/README.md") then
table.insert(props, { "readme", "README.md" }) table.insert(props, { "readme", "README.md" })
end end
Util.ls(plugin.dir .. "/doc", function(_, name) Util.ls(plugin.dir .. "/doc", function(path, name)
if name:find("%.txt$") then if name:sub(-3) == "txt" then
-- FIXME: the help tag is wrong local data = Util.read_file(path)
table.insert(props, { "help", "|" .. name:gsub("%.txt", "") .. "|" }) local tag = data:match("%*(%S-)%*")
if tag then
table.insert(props, { "help", "|" .. tag .. "|" })
end
end end
end) end)
@ -398,8 +401,12 @@ function M:details(plugin)
if plugin[handler] then if plugin[handler] then
table.insert(props, { table.insert(props, {
handler, handler,
type(plugin[handler]) == "string" and plugin[handler] or table.concat(plugin[handler], ", "), function()
"@string", for _, value in ipairs(plugin[handler]) do
self:reason({ [handler] = value })
self:append(" ")
end
end,
}) })
end end
end end
@ -410,7 +417,11 @@ function M:details(plugin)
end end
for _, prop in ipairs(props) do for _, prop in ipairs(props) do
self:append(prop[1] .. string.rep(" ", width - #prop[1] + 1), "LazyKey", { indent = 6 }) self:append(prop[1] .. string.rep(" ", width - #prop[1] + 1), "LazyKey", { indent = 6 })
if type(prop[2]) == "function" then
prop[2]()
else
self:append(prop[2], prop[3] or "LazyValue") self:append(prop[2], prop[3] or "LazyValue")
end
self:nl() self:nl()
end end
self:nl() self:nl()
@ -430,7 +441,7 @@ function M:profile()
local data = type(entry.data) == "string" and { source = entry.data } or entry.data local data = type(entry.data) == "string" and { source = entry.data } or entry.data
data.time = entry.time data.time = entry.time
local symbol = symbols[depth] or symbols[#symbols] local symbol = symbols[depth] or symbols[#symbols]
self:append((" "):rep(depth)):append(" " .. symbol, "LazySpecial") self:append((" "):rep(depth)):append(" " .. symbol, "LazySpecial"):append(" ")
self:reason(data, { time_right = true }) self:reason(data, { time_right = true })
self:nl() self:nl()
@ -460,9 +471,10 @@ function M:debug()
plugins = vim.tbl_values(plugins) plugins = vim.tbl_values(plugins)
table.sort(plugins) table.sort(plugins)
self:append("", "LazySpecial", { indent = 2 }) self:append("", "LazySpecial", { indent = 2 })
self:reason({ [type] = value }, { time_right = true }) self:reason({ [type] = value })
for _, plugin in pairs(plugins) do for _, plugin in pairs(plugins) do
self:reason({ plugin = plugin }, { time_right = true }) self:append(" ")
self:reason({ plugin = plugin })
end end
self:nl() self:nl()
end end