From ea738166651a06e7f7b0b776a1233fccaa1610e5 Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Fri, 30 Aug 2024 02:08:59 -0400 Subject: [PATCH] fix(warning): taken into account silent_warning (fixes #385) (#388) Signed-off-by: Aaron Pham --- lua/avante/api.lua | 3 ++- lua/avante/config.lua | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/avante/api.lua b/lua/avante/api.lua index f0e6bf6..732aee3 100644 --- a/lua/avante/api.lua +++ b/lua/avante/api.lua @@ -1,3 +1,4 @@ +local Config = require("avante.config") local Utils = require("avante.utils") ---@class avante.ApiToggle @@ -17,7 +18,7 @@ return setmetatable({}, { ---@class AvailableApi: ApiCaller ---@field api? boolean local has = module[k] - if type(has) ~= "table" or not has.api then + if type(has) ~= "table" or not has.api and not Config.silent_warning then Utils.warn(k .. " is not a valid avante's API method", { once = true }) return end diff --git a/lua/avante/config.lua b/lua/avante/config.lua index 6d88a62..dc29c29 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -233,7 +233,7 @@ M = setmetatable(M, { M.support_paste_image = function() local supported = Utils.has("img-clip.nvim") or Utils.has("img-clip") - if not supported then + if not supported and not M.options.silent_warning then Utils.warn("img-clip.nvim is not installed. Pasting image will be disabled.", { once = true }) end return supported