mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(profiler): on_close can now be a function
This commit is contained in:
parent
971229e8a9
commit
48a58792a0
1 changed files with 12 additions and 3 deletions
|
@ -144,7 +144,7 @@ local defaults = {
|
|||
pattern = nil, -- pattern to match for the autocmd
|
||||
pick = true, -- show a picker after starting the profiler (uses the `startup` preset)
|
||||
},
|
||||
---@type table<string, snacks.profiler.Pick|fun():snacks.profiler.Pick>
|
||||
---@type table<string, snacks.profiler.Pick|fun():snacks.profiler.Pick?>
|
||||
presets = {
|
||||
startup = { min_time = 1, sort = false },
|
||||
on_stop = {},
|
||||
|
@ -319,10 +319,19 @@ end
|
|||
---@param opts? snacks.profiler.Pick.spec
|
||||
function M.pick(opts)
|
||||
load()
|
||||
opts = type(opts) == "function" and opts() or opts or {}
|
||||
if type(opts) == "function" then
|
||||
opts = opts()
|
||||
if not opts then
|
||||
return
|
||||
end
|
||||
end
|
||||
opts = opts or {}
|
||||
if opts.preset then
|
||||
local preset = M.config.presets[opts.preset]
|
||||
preset = type(preset) == "function" and preset() or preset
|
||||
preset = type(preset) == "function" and preset()
|
||||
if not preset then
|
||||
return
|
||||
end
|
||||
opts = vim.tbl_deep_extend("force", {}, preset, opts)
|
||||
end
|
||||
---@cast opts snacks.profiler.Pick
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue