mirror of https://github.com/folke/lazy.nvim.git
feat: new render features like profile etc
This commit is contained in:
parent
d7dbe1a43f
commit
48199f8031
|
@ -7,7 +7,7 @@ M.colors = {
|
||||||
Muted = "Comment",
|
Muted = "Comment",
|
||||||
Normal = "NormalFloat",
|
Normal = "NormalFloat",
|
||||||
Commit = "@variable.builtin",
|
Commit = "@variable.builtin",
|
||||||
Key = "@comment",
|
Key = "Conceal",
|
||||||
Value = "@string",
|
Value = "@string",
|
||||||
ProgressDone = {
|
ProgressDone = {
|
||||||
bold = true,
|
bold = true,
|
||||||
|
@ -16,6 +16,12 @@ M.colors = {
|
||||||
},
|
},
|
||||||
ProgressTodo = "LineNr",
|
ProgressTodo = "LineNr",
|
||||||
Special = "@punctuation.special",
|
Special = "@punctuation.special",
|
||||||
|
LoaderPlugin = "Special",
|
||||||
|
LoaderEvent = "Constant",
|
||||||
|
LoaderKeys = "Statement",
|
||||||
|
LoaderStart = "@field",
|
||||||
|
LoaderSource = "Character",
|
||||||
|
LoaderCmd = "Operator"
|
||||||
}
|
}
|
||||||
|
|
||||||
M.did_setup = false
|
M.did_setup = false
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
local Config = require("lazy.core.config")
|
local Config = require("lazy.core.config")
|
||||||
local Util = require("lazy.core.util")
|
local Util = require("lazy.util")
|
||||||
local Manager = require("lazy.manager")
|
|
||||||
local Sections = require("lazy.view.sections")
|
local Sections = require("lazy.view.sections")
|
||||||
|
local Loader = require("lazy.core.loader")
|
||||||
|
local State = require("lazy.core.state")
|
||||||
|
|
||||||
local Text = require("lazy.view.text")
|
local Text = require("lazy.view.text")
|
||||||
|
|
||||||
|
@ -32,10 +33,10 @@ function M:update()
|
||||||
self._diagnostics = {}
|
self._diagnostics = {}
|
||||||
self.plugin_range = {}
|
self.plugin_range = {}
|
||||||
|
|
||||||
Manager.check_clean()
|
State.update_state(true)
|
||||||
|
|
||||||
self.plugins = vim.tbl_values(Config.plugins)
|
self.plugins = vim.tbl_values(Config.plugins)
|
||||||
vim.list_extend(self.plugins, vim.tbl_values(Manager.to_clean))
|
vim.list_extend(self.plugins, vim.tbl_values(Config.to_clean))
|
||||||
table.sort(self.plugins, function(a, b)
|
table.sort(self.plugins, function(a, b)
|
||||||
return a.name < b.name
|
return a.name < b.name
|
||||||
end)
|
end)
|
||||||
|
@ -168,18 +169,37 @@ function M:reason(plugin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:append(" " .. math.floor((reason.time or 0) / 1e6 * 100) / 100 .. "ms", "Bold")
|
self:append(" " .. math.floor((reason.time or 0) / 1e6 * 100) / 100 .. "ms", "Bold")
|
||||||
|
self:append(" ")
|
||||||
|
-- self:append(" (", "Conceal")
|
||||||
|
local first = true
|
||||||
for key, value in pairs(reason) do
|
for key, value in pairs(reason) do
|
||||||
if key == "require" then
|
if key == "require" then
|
||||||
self:append("require", "@function.builtin")
|
-- self:append("require", "@function.builtin")
|
||||||
self:append("(", "@punctuation.bracket")
|
-- self:append("(", "@punctuation.bracket")
|
||||||
self:append('"' .. value .. '"', "@string")
|
-- self:append('"' .. value .. '"', "@string")
|
||||||
self:append(")", "@punctuation.bracket")
|
-- self:append(")", "@punctuation.bracket")
|
||||||
elseif key ~= "time" then
|
elseif key ~= "time" then
|
||||||
|
if first then
|
||||||
|
first = false
|
||||||
|
else
|
||||||
|
self:append(" ")
|
||||||
|
end
|
||||||
|
if key == "event" then
|
||||||
|
value = value:match("User (.*)") or value
|
||||||
|
end
|
||||||
|
local hl = "LazyLoader" .. key:sub(1, 1):upper() .. key:sub(2)
|
||||||
|
local icon = Config.options.view.icons[key]
|
||||||
|
if icon then
|
||||||
|
self:append(icon .. " ", hl)
|
||||||
|
self:append(value, hl)
|
||||||
|
else
|
||||||
self:append(key .. " ", "@field")
|
self:append(key .. " ", "@field")
|
||||||
self:append(value .. " ", "@string")
|
self:append(value, hl)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- self:append(")", "Conceal")
|
||||||
|
end
|
||||||
|
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
function M:diagnostics(plugin)
|
function M:diagnostics(plugin)
|
||||||
|
@ -249,8 +269,11 @@ function M:log(task)
|
||||||
local log = vim.trim(task.output)
|
local log = vim.trim(task.output)
|
||||||
if log ~= "" then
|
if log ~= "" then
|
||||||
local lines = vim.split(log, "\n")
|
local lines = vim.split(log, "\n")
|
||||||
for l, line in ipairs(lines) do
|
for _, line in ipairs(lines) do
|
||||||
local ref, msg, time = line:match("^(%w+) (.*) (%(.*%))$")
|
local ref, msg, time = line:match("^(%w+) (.*) (%(.*%))$")
|
||||||
|
if msg:find("^%S+!:") then
|
||||||
|
self:diagnostic({ message = "Breaking Changes", severity = vim.diagnostic.severity.WARN })
|
||||||
|
end
|
||||||
self:append(ref .. " ", "LazyCommit", { indent = 6 })
|
self:append(ref .. " ", "LazyCommit", { indent = 6 })
|
||||||
self:append(vim.trim(msg)):highlight({
|
self:append(vim.trim(msg)):highlight({
|
||||||
["#%d+"] = "Number",
|
["#%d+"] = "Number",
|
||||||
|
@ -280,12 +303,22 @@ function M:details(plugin)
|
||||||
table.insert(props, { "readme", "README.md" })
|
table.insert(props, { "readme", "README.md" })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for _, loader in ipairs(Loader.types) do
|
||||||
|
if plugin[loader] then
|
||||||
|
table.insert(props, {
|
||||||
|
loader,
|
||||||
|
type(plugin[loader]) == "string" and plugin[loader] or table.concat(plugin[loader], ", "),
|
||||||
|
"@string",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local width = 0
|
local width = 0
|
||||||
for _, prop in ipairs(props) do
|
for _, prop in ipairs(props) do
|
||||||
width = math.max(width, #prop[1])
|
width = math.max(width, #prop[1])
|
||||||
end
|
end
|
||||||
for _, prop in ipairs(props) do
|
for _, prop in ipairs(props) do
|
||||||
self:append(prop[1] .. string.rep(" ", width - #prop[1]), "LazyKey", { indent = 6 })
|
self:append(prop[1] .. string.rep(" ", width - #prop[1] + 1), "LazyKey", { indent = 6 })
|
||||||
self:append(prop[2], prop[3] or "LazyValue")
|
self:append(prop[2], prop[3] or "LazyValue")
|
||||||
self:nl()
|
self:nl()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue