mirror of https://github.com/folke/lazy.nvim.git
feat(ui): improvements to profiling and rendering of loaded reasons
This commit is contained in:
parent
5eb2622a4e
commit
714bc0a136
|
@ -36,6 +36,7 @@ M.defaults = {
|
|||
border = "none",
|
||||
icons = {
|
||||
start = "",
|
||||
init = " ",
|
||||
plugin = " ",
|
||||
source = " ",
|
||||
config = "",
|
||||
|
|
|
@ -28,15 +28,15 @@ function M.setup()
|
|||
end
|
||||
|
||||
function M.init_plugins()
|
||||
Util.track("plugin_init")
|
||||
Util.track({ start = "init" })
|
||||
for _, plugin in pairs(Config.plugins) do
|
||||
if plugin.init then
|
||||
Util.track({ plugin = plugin.name, start = "init" })
|
||||
Util.track({ plugin = plugin.name, init = "init" })
|
||||
Util.try(plugin.init, "Failed to run `init` for **" .. plugin.name .. "**")
|
||||
Util.track()
|
||||
end
|
||||
if plugin.lazy == false then
|
||||
M.load(plugin, { start = "start" })
|
||||
M.load(plugin, { start = "startup" })
|
||||
end
|
||||
end
|
||||
Util.track()
|
||||
|
|
|
@ -11,7 +11,7 @@ local M = {}
|
|||
---@field build? string|fun(LazyPlugin)
|
||||
|
||||
---@class LazyPluginState
|
||||
---@field loaded? {[string]:string, time:number}
|
||||
---@field loaded? {[string]:string}|{time:number}
|
||||
---@field installed boolean
|
||||
---@field tasks? LazyTask[]
|
||||
---@field dirty? boolean
|
||||
|
|
|
@ -3,17 +3,16 @@ local M = {}
|
|||
---@param spec LazySpec Should be a module name to load, or a plugin spec
|
||||
---@param opts? LazyConfig
|
||||
function M.setup(spec, opts)
|
||||
local module_start = vim.loop.hrtime()
|
||||
local start = vim.loop.hrtime()
|
||||
require("lazy.core.module").setup()
|
||||
local Util = require("lazy.core.util")
|
||||
local Config = require("lazy.core.config")
|
||||
local Loader = require("lazy.core.loader")
|
||||
local Plugin = require("lazy.core.plugin")
|
||||
|
||||
Util.track("module", vim.loop.hrtime() - module_start)
|
||||
|
||||
Util.track("setup")
|
||||
Util.track({ plugin = "lazy.nvim" })
|
||||
|
||||
Util.track("module", vim.loop.hrtime() - start)
|
||||
Util.track("config")
|
||||
Config.setup(spec, opts)
|
||||
Util.track()
|
||||
|
@ -24,14 +23,14 @@ function M.setup(spec, opts)
|
|||
Loader.setup()
|
||||
Util.track()
|
||||
|
||||
local lazy_delta = vim.loop.hrtime() - module_start
|
||||
local delta = vim.loop.hrtime() - start
|
||||
|
||||
Util.track() -- end setup
|
||||
Util.track().time = delta -- end setup
|
||||
|
||||
Loader.init_plugins()
|
||||
|
||||
if Config.plugins["lazy.nvim"] then
|
||||
Config.plugins["lazy.nvim"]._.loaded.time = lazy_delta
|
||||
Config.plugins["lazy.nvim"]._.loaded = { time = delta, source = "init.lua" }
|
||||
end
|
||||
|
||||
vim.cmd("do User LazyDone")
|
||||
|
|
|
@ -217,7 +217,16 @@ function M:reason(reason, opts)
|
|||
self:append(" ")
|
||||
-- self:append(" (", "Conceal")
|
||||
local first = true
|
||||
for key, value in pairs(reason) do
|
||||
local keys = vim.tbl_keys(reason)
|
||||
table.sort(keys)
|
||||
if vim.tbl_contains(keys, "plugin") then
|
||||
keys = vim.tbl_filter(function(key)
|
||||
return key ~= "plugin"
|
||||
end, keys)
|
||||
table.insert(keys, "plugin")
|
||||
end
|
||||
for _, key in ipairs(keys) do
|
||||
local value = reason[key]
|
||||
if type(key) == "number" then
|
||||
elseif key == "require" then
|
||||
-- self:append("require", "@function.builtin")
|
||||
|
|
Loading…
Reference in New Issue