chore(config): add silent_warning options (#378)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
bd500feeec
commit
b43377c044
@ -7,11 +7,10 @@ local Utils = require("avante.utils")
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@class avante.Config
|
---@class avante.Config
|
||||||
|
---@field silent_warning boolean will be determined from debug
|
||||||
M.defaults = {
|
M.defaults = {
|
||||||
debug = false,
|
debug = false,
|
||||||
---Currently, default supported providers include "claude", "openai", "azure", "gemini"
|
---@alias Provider "claude" | "openai" | "azure" | "gemini" | "cohere" | string
|
||||||
---For custom provider, see README.md
|
|
||||||
---@alias Provider "claude" | "openai" | "azure" | "gemini" | string
|
|
||||||
provider = "claude", -- Only recommend using Claude
|
provider = "claude", -- Only recommend using Claude
|
||||||
---@type AvanteSupportedProvider
|
---@type AvanteSupportedProvider
|
||||||
openai = {
|
openai = {
|
||||||
@ -170,6 +169,10 @@ function M.setup(opts)
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
if not M.options.silent_warning then
|
||||||
|
-- set silent_warning to true if debug is false
|
||||||
|
M.options.silent_warning = not M.options.debug
|
||||||
|
end
|
||||||
|
|
||||||
M.diff = vim.tbl_deep_extend(
|
M.diff = vim.tbl_deep_extend(
|
||||||
"force",
|
"force",
|
||||||
@ -186,18 +189,15 @@ function M.setup(opts)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
M.support_paste_image = function()
|
|
||||||
local supported = Utils.has("img-clip.nvim") or Utils.has("img-clip")
|
|
||||||
if not supported then
|
|
||||||
Utils.warn("img-clip.nvim is not installed. Pasting image will be disabled.", { once = true })
|
|
||||||
end
|
|
||||||
return supported
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param opts? avante.Config
|
---@param opts? avante.Config
|
||||||
function M.override(opts)
|
function M.override(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
M.options = vim.tbl_deep_extend("force", M.options, opts)
|
M.options = vim.tbl_deep_extend("force", M.options, opts)
|
||||||
|
if not M.options.silent_warning then
|
||||||
|
-- set silent_warning to true if debug is false
|
||||||
|
M.options.silent_warning = not M.options.debug
|
||||||
|
end
|
||||||
|
|
||||||
M.diff = vim.tbl_deep_extend(
|
M.diff = vim.tbl_deep_extend(
|
||||||
"force",
|
"force",
|
||||||
{},
|
{},
|
||||||
@ -205,6 +205,12 @@ function M.override(opts)
|
|||||||
{ mappings = M.options.mappings.diff, highlights = M.options.highlights.diff }
|
{ mappings = M.options.mappings.diff, highlights = M.options.highlights.diff }
|
||||||
)
|
)
|
||||||
M.hints = vim.tbl_deep_extend("force", {}, M.options.hints)
|
M.hints = vim.tbl_deep_extend("force", {}, M.options.hints)
|
||||||
|
|
||||||
|
if next(M.options.vendors) ~= nil then
|
||||||
|
for k, v in pairs(M.options.vendors) do
|
||||||
|
M.options.vendors[k] = type(v) == "function" and v() or v
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
M = setmetatable(M, {
|
M = setmetatable(M, {
|
||||||
@ -215,7 +221,15 @@ M = setmetatable(M, {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
function M.get_window_width()
|
M.support_paste_image = function()
|
||||||
|
local supported = Utils.has("img-clip.nvim") or Utils.has("img-clip")
|
||||||
|
if not supported then
|
||||||
|
Utils.warn("img-clip.nvim is not installed. Pasting image will be disabled.", { once = true })
|
||||||
|
end
|
||||||
|
return supported
|
||||||
|
end
|
||||||
|
|
||||||
|
M.get_window_width = function()
|
||||||
return math.ceil(vim.o.columns * (M.windows.width / 100))
|
return math.ceil(vim.o.columns * (M.windows.width / 100))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -253,7 +267,7 @@ M.BASE_PROVIDER_KEYS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
---@return {width: integer, height: integer}
|
---@return {width: integer, height: integer}
|
||||||
function M.get_sidebar_layout_options()
|
M.get_sidebar_layout_options = function()
|
||||||
local width = M.get_window_width()
|
local width = M.get_window_width()
|
||||||
local height = vim.o.lines
|
local height = vim.o.lines
|
||||||
return { width = width, height = height }
|
return { width = width, height = height }
|
||||||
|
@ -321,6 +321,10 @@ end
|
|||||||
---@param msg string|string[]
|
---@param msg string|string[]
|
||||||
---@param opts? LazyNotifyOpts
|
---@param opts? LazyNotifyOpts
|
||||||
function M.warn(msg, opts)
|
function M.warn(msg, opts)
|
||||||
|
if require("avante.config").options.silent_warning then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
opts.level = vim.log.levels.WARN
|
opts.level = vim.log.levels.WARN
|
||||||
M.notify(msg, opts)
|
M.notify(msg, opts)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user