feat: silence debug msg (#636)

This commit is contained in:
yetone
2024-09-26 11:18:40 +08:00
committed by GitHub
parent 0d90c047ef
commit 22243bc316
4 changed files with 20 additions and 18 deletions

View File

@@ -123,7 +123,7 @@ M.safe_keymap_set = function(mode, lhs, rhs, opts)
ok, H = pcall(require, "lazy.core.handler")
if not ok then
M.debug("lazy.nvim is not available. Avante will use vim.keymap.set", { once = true })
M.debug("lazy.nvim is not available. Avante will use vim.keymap.set")
vim.keymap.set(mode, lhs, rhs, opts)
return
end
@@ -324,18 +324,21 @@ function M.warn(msg, opts)
M.notify(msg, opts)
end
---@param msg string|table
---@param opts? LazyNotifyOpts
function M.debug(msg, opts)
function M.debug(...)
if not require("avante.config").options.debug then return end
opts = opts or {}
if opts.title then opts.title = "avante.nvim: " .. opts.title end
if type(msg) == "string" then
M.notify(msg, opts)
else
opts.lang = "lua"
M.notify(vim.inspect(msg), opts)
local args = { ... }
if #args == 0 then return end
local timestamp = os.date("%Y-%m-%d %H:%M:%S")
local formated_args = { "[" .. timestamp .. "] [AVANTE] [DEBUG]" }
for _, arg in ipairs(args) do
if type(arg) == "string" then
table.insert(formated_args, arg)
else
table.insert(formated_args, vim.inspect(arg))
end
end
print(unpack(formated_args))
end
function M.tbl_indexof(tbl, value)