mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
refactor(util): improved notify functions
This commit is contained in:
parent
1f17bb79b7
commit
d3a963d51c
3 changed files with 37 additions and 26 deletions
|
@ -105,25 +105,24 @@ function M.disable()
|
|||
_G.loadfile = M._loadfile
|
||||
M.enabled = false
|
||||
if M.debug and vim.tbl_count(M.topmods) > 1 then
|
||||
M.log(M.topmods, vim.log.levels.WARN, { title = "topmods" })
|
||||
M.log(M.topmods, { level = vim.log.levels.WARN, title = "topmods" })
|
||||
end
|
||||
if M.debug and false then
|
||||
local stats = vim.deepcopy(M.stats)
|
||||
stats.time = (stats.time or 0) / 1e6
|
||||
stats.find.time = (stats.find.time or 0) / 1e6
|
||||
stats.autoload.time = (stats.autoload.time or 0) / 1e6
|
||||
M.log(stats, nil, { title = "stats" })
|
||||
M.log(stats, { title = "stats" })
|
||||
end
|
||||
end
|
||||
|
||||
---@param msg string|table
|
||||
---@param level? number
|
||||
---@param opts? {lang:string, title:string}
|
||||
function M.log(msg, level, opts)
|
||||
---@param opts? LazyNotifyOpts
|
||||
function M.log(msg, opts)
|
||||
if M.debug then
|
||||
msg = vim.deepcopy(msg)
|
||||
vim.schedule(function()
|
||||
require("lazy.core.util").debug(msg, level, opts)
|
||||
require("lazy.core.util").debug(msg, opts)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
@ -208,7 +207,7 @@ function M.load(modkey, modpath)
|
|||
entry.hash = hash
|
||||
|
||||
if M.debug then
|
||||
M.log("`" .. modpath .. "`", vim.log.levels.WARN, { title = "Cache.load" })
|
||||
M.log("`" .. modpath .. "`", { level = vim.log.levels.WARN, title = "Cache.load" })
|
||||
end
|
||||
|
||||
chunk, err = M._loadfile(entry.modpath)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue