@@ -60,6 +60,8 @@ function M:update()
60
60
61
61
if mode == " help" then
62
62
self :help ()
63
+ elseif mode == " profile" then
64
+ self :profile ()
63
65
else
64
66
for _ , section in ipairs (Sections ) do
65
67
self :section (section )
@@ -109,7 +111,7 @@ function M:title()
109
111
end
110
112
self :nl ()
111
113
112
- if View .mode ~= " help" then
114
+ if View .mode ~= " help" and View . mode ~= " profile " then
113
115
if self .progress .done < self .progress .total then
114
116
self :append (" Tasks: " , " LazyH2" )
115
117
self :append (self .progress .done .. " /" .. self .progress .total , " LazyMuted" )
@@ -181,9 +183,14 @@ function M:diagnostic(diag)
181
183
table.insert (self ._diagnostics , diag )
182
184
end
183
185
184
- --- @param plugin LazyPlugin
185
- function M :reason (plugin )
186
- local reason = vim .deepcopy (plugin ._ .loaded or {})
186
+ --- @param reason ? { [string] : string , time : number }
187
+ --- @param opts ? { time_right ?: boolean }
188
+ function M :reason (reason , opts )
189
+ opts = opts or {}
190
+ if not reason then
191
+ return
192
+ end
193
+ reason = vim .deepcopy (reason )
187
194
--- @type string ?
188
195
local source = reason .source
189
196
if source then
@@ -207,12 +214,16 @@ function M:reason(plugin)
207
214
end
208
215
end
209
216
end
210
- self :append (" " .. math.floor ((reason .time or 0 ) / 1e6 * 100 ) / 100 .. " ms" , " Bold" )
217
+ local time = " " .. math.floor ((reason .time or 0 ) / 1e6 * 100 ) / 100 .. " ms"
218
+ if not opts .time_right then
219
+ self :append (time , " Bold" )
220
+ end
211
221
self :append (" " )
212
222
-- self:append(" (", "Conceal")
213
223
local first = true
214
224
for key , value in pairs (reason ) do
215
- if key == " require" then
225
+ if type (key ) == " number" then
226
+ elseif key == " require" then
216
227
-- self:append("require", "@function.builtin")
217
228
-- self:append("(", "@punctuation.bracket")
218
229
-- self:append('"' .. value .. '"', "@string")
@@ -237,6 +248,9 @@ function M:reason(plugin)
237
248
end
238
249
end
239
250
end
251
+ if opts .time_right then
252
+ self :append (time , " Bold" )
253
+ end
240
254
-- self:append(")", "Conceal")
241
255
end
242
256
@@ -270,10 +284,14 @@ end
270
284
271
285
--- @param plugin LazyPlugin
272
286
function M :plugin (plugin )
273
- self :append (" - " , " LazySpecial" ):append (plugin .name )
287
+ if plugin ._ .loaded then
288
+ self :append (" ● " , " LazySpecial" ):append (plugin .name )
289
+ else
290
+ self :append (" ○ " , " LazySpecial" ):append (plugin .name )
291
+ end
274
292
local plugin_start = self :row ()
275
293
if plugin ._ .loaded then
276
- self :reason (plugin )
294
+ self :reason (plugin . _ . loaded )
277
295
end
278
296
self :diagnostics (plugin )
279
297
self :nl ()
@@ -377,4 +395,32 @@ function M:details(plugin)
377
395
self :nl ()
378
396
end
379
397
398
+ function M :profile ()
399
+ self :append (" Profile" , " LazyH2" ):nl ():nl ()
400
+ local symbols = {
401
+ " ●" ,
402
+ " ➜" ,
403
+ " ★" ,
404
+ " ‒" ,
405
+ }
406
+
407
+ --- @param entry LazyProfile
408
+ local function _profile (entry , depth )
409
+ local data = type (entry .data ) == " string" and { source = entry .data } or entry .data
410
+ data .time = entry .time
411
+ local symbol = symbols [depth ] or symbols [# symbols ]
412
+ self :append ((" " ):rep (depth )):append (" " .. symbol , " LazySpecial" )
413
+ self :reason (data , { time_right = true })
414
+ self :nl ()
415
+
416
+ for _ , child in ipairs (entry ) do
417
+ _profile (child , depth + 1 )
418
+ end
419
+ end
420
+
421
+ for _ , entry in ipairs (Util ._profiles [1 ]) do
422
+ _profile (entry , 1 )
423
+ end
424
+ end
425
+
380
426
return M
0 commit comments