mirror of https://github.com/folke/lazy.nvim.git
feat(ui): added debug interface to inspect active handlers and the module cache
This commit is contained in:
parent
d36ad410ee
commit
6d68cc6ea2
|
@ -16,12 +16,13 @@ M.colors = {
|
||||||
},
|
},
|
||||||
ProgressTodo = "LineNr",
|
ProgressTodo = "LineNr",
|
||||||
Special = "@punctuation.special",
|
Special = "@punctuation.special",
|
||||||
LoaderPlugin = "Special",
|
HandlerPlugin = "Special",
|
||||||
LoaderEvent = "Constant",
|
HandlerEvent = "Constant",
|
||||||
LoaderKeys = "Statement",
|
HandlerKeys = "Statement",
|
||||||
LoaderStart = "@field",
|
HandlerStart = "@field",
|
||||||
LoaderSource = "Character",
|
HandlerSource = "Character",
|
||||||
LoaderCmd = "Operator",
|
HandlerFt = "Character",
|
||||||
|
HandlerCmd = "Operator",
|
||||||
Button = "CursorLine",
|
Button = "CursorLine",
|
||||||
ButtonActive = "Visual",
|
ButtonActive = "Visual",
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,9 @@ M.commands = {
|
||||||
help = function()
|
help = function()
|
||||||
View.show("help")
|
View.show("help")
|
||||||
end,
|
end,
|
||||||
|
debug = function()
|
||||||
|
View.show("debug")
|
||||||
|
end,
|
||||||
profile = function()
|
profile = function()
|
||||||
View.show("profile")
|
View.show("profile")
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -13,6 +13,7 @@ M.modes = {
|
||||||
{ name = "log", key = "L", desc = "Show recent updates for all plugins" },
|
{ name = "log", key = "L", desc = "Show recent updates for all plugins" },
|
||||||
{ name = "restore", key = "R", desc = "Updates all plugins to the state in the lockfile" },
|
{ name = "restore", key = "R", desc = "Updates all plugins to the state in the lockfile" },
|
||||||
{ name = "profile", key = "P", desc = "Show detailed profiling", toggle = true },
|
{ name = "profile", key = "P", desc = "Show detailed profiling", toggle = true },
|
||||||
|
{ name = "debug", key = "D", desc = "Show debug information", toggle = true },
|
||||||
{ name = "help", key = "?", hide = true, desc = "Toggle this help page", toggle = true },
|
{ name = "help", key = "?", hide = true, desc = "Toggle this help page", toggle = true },
|
||||||
|
|
||||||
{ plugin = true, name = "update", key = "u", desc = "Update this plugin. This will also update the lockfile" },
|
{ plugin = true, name = "update", key = "u", desc = "Update this plugin. This will also update the lockfile" },
|
||||||
|
|
|
@ -60,6 +60,8 @@ function M:update()
|
||||||
self:help()
|
self:help()
|
||||||
elseif mode == "profile" then
|
elseif mode == "profile" then
|
||||||
self:profile()
|
self:profile()
|
||||||
|
elseif mode == "debug" then
|
||||||
|
self:debug()
|
||||||
else
|
else
|
||||||
for _, section in ipairs(Sections) do
|
for _, section in ipairs(Sections) do
|
||||||
self:section(section)
|
self:section(section)
|
||||||
|
@ -109,7 +111,7 @@ function M:title()
|
||||||
end
|
end
|
||||||
self:nl()
|
self:nl()
|
||||||
|
|
||||||
if View.mode ~= "help" and View.mode ~= "profile" then
|
if View.mode ~= "help" and View.mode ~= "profile" and View.mode ~= "debug" then
|
||||||
if self.progress.done < self.progress.total then
|
if self.progress.done < self.progress.total then
|
||||||
self:append("Tasks: ", "LazyH2")
|
self:append("Tasks: ", "LazyH2")
|
||||||
self:append(self.progress.done .. "/" .. self.progress.total, "LazyMuted")
|
self:append(self.progress.done .. "/" .. self.progress.total, "LazyMuted")
|
||||||
|
@ -208,8 +210,8 @@ function M:reason(reason, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local time = " " .. math.floor((reason.time or 0) / 1e6 * 100) / 100 .. "ms"
|
local time = reason.time and (" " .. math.floor(reason.time / 1e6 * 100) / 100 .. "ms")
|
||||||
if not opts.time_right then
|
if time and not opts.time_right then
|
||||||
self:append(time, "Bold")
|
self:append(time, "Bold")
|
||||||
end
|
end
|
||||||
self:append(" ")
|
self:append(" ")
|
||||||
|
@ -227,10 +229,6 @@ function M:reason(reason, opts)
|
||||||
local value = reason[key]
|
local value = reason[key]
|
||||||
if type(key) == "number" then
|
if type(key) == "number" then
|
||||||
elseif key == "require" then
|
elseif key == "require" then
|
||||||
-- self:append("require", "@function.builtin")
|
|
||||||
-- self:append("(", "@punctuation.bracket")
|
|
||||||
-- self:append('"' .. value .. '"', "@string")
|
|
||||||
-- self:append(")", "@punctuation.bracket")
|
|
||||||
elseif key ~= "time" then
|
elseif key ~= "time" then
|
||||||
if first then
|
if first then
|
||||||
first = false
|
first = false
|
||||||
|
@ -239,8 +237,10 @@ function M:reason(reason, opts)
|
||||||
end
|
end
|
||||||
if key == "event" then
|
if key == "event" then
|
||||||
value = value:match("User (.*)") or value
|
value = value:match("User (.*)") or value
|
||||||
|
elseif key == "ft" then
|
||||||
|
value = value:match("FileType (.*)") or value
|
||||||
end
|
end
|
||||||
local hl = "LazyLoader" .. key:sub(1, 1):upper() .. key:sub(2)
|
local hl = "LazyHandler" .. key:sub(1, 1):upper() .. key:sub(2)
|
||||||
local icon = Config.options.ui.icons[key]
|
local icon = Config.options.ui.icons[key]
|
||||||
if icon then
|
if icon then
|
||||||
self:append(icon .. " ", hl)
|
self:append(icon .. " ", hl)
|
||||||
|
@ -251,7 +251,7 @@ function M:reason(reason, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if opts.time_right then
|
if time and opts.time_right then
|
||||||
self:append(time, "Bold")
|
self:append(time, "Bold")
|
||||||
end
|
end
|
||||||
-- self:append(")", "Conceal")
|
-- self:append(")", "Conceal")
|
||||||
|
@ -432,4 +432,37 @@ function M:profile()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M:debug()
|
||||||
|
self:append("Active Handlers", "LazyH2"):nl()
|
||||||
|
self
|
||||||
|
:append(
|
||||||
|
"This shows only the lazy handlers that are still active. When a plugin loads, its handlers are removed",
|
||||||
|
"Comment",
|
||||||
|
{ indent = 2 }
|
||||||
|
)
|
||||||
|
:nl()
|
||||||
|
|
||||||
|
Util.foreach(require("lazy.core.handler").handlers, function(type, handler)
|
||||||
|
Util.foreach(handler.active, function(value, plugins)
|
||||||
|
if not vim.tbl_isempty(plugins) then
|
||||||
|
plugins = vim.tbl_values(plugins)
|
||||||
|
table.sort(plugins)
|
||||||
|
self:append("●", "LazySpecial", { indent = 2 })
|
||||||
|
self:reason({ [type] = value }, { time_right = true })
|
||||||
|
for _, plugin in pairs(plugins) do
|
||||||
|
self:reason({ plugin = plugin }, { time_right = true })
|
||||||
|
end
|
||||||
|
self:nl()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
self:nl()
|
||||||
|
self:append("Cache", "LazyH2"):nl()
|
||||||
|
local Cache = require("lazy.core.cache")
|
||||||
|
Util.foreach(Cache.cache, function(modname, entry)
|
||||||
|
local kb = math.floor(#entry.chunk / 10.24) / 100
|
||||||
|
self:append("● ", "LazySpecial", { indent = 2 }):append(modname):append(" " .. kb .. "Kb", "Bold"):nl()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in New Issue