From 12bdb66ea4749f9f59861e7165a4de6cfbf4eb22 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Thu, 5 Jun 2025 11:29:21 -0500 Subject: [PATCH] chore: vim.validate deprecation change (#2162) --- lua/avante/config.lua | 18 +++++++++++++++--- lua/avante/highlights.lua | 6 +++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lua/avante/config.lua b/lua/avante/config.lua index 7f5bff5..a6c36b8 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -573,7 +573,11 @@ M._options = {} ---@param opts? avante.Config function M.setup(opts) - vim.validate({ opts = { opts, "table", true } }) + if vim.fn.has("nvim-0.11") == 1 then + vim.validate("opts", opts, "table", true) + else + vim.validate({ opts = { opts, "table", true } }) + end opts = opts or {} @@ -719,7 +723,11 @@ function M.setup(opts) ) end - vim.validate({ provider = { M._options.provider, "string", false } }) + if vim.fn.has("nvim-0.11") == 1 then + vim.validate("provider", M._options.provider, "string", false) + else + vim.validate({ provider = { M._options.provider, "string", false } }) + end for k, v in pairs(M._options.providers) do M._options.providers[k] = type(v) == "function" and v() or v @@ -728,7 +736,11 @@ end ---@param opts table function M.override(opts) - vim.validate({ opts = { opts, "table", true } }) + if vim.fn.has("nvim-0.11") == 1 then + vim.validate("opts", opts, "table", true) + else + vim.validate({ opts = { opts, "table", true } }) + end M._options = vim.tbl_deep_extend("force", M._options, opts or {}) diff --git a/lua/avante/highlights.lua b/lua/avante/highlights.lua index 85a5014..f28bc10 100644 --- a/lua/avante/highlights.lua +++ b/lua/avante/highlights.lua @@ -172,7 +172,11 @@ setmetatable(M, { ---@param rgb_24bit number 24-bit RGB value ---@return {r: integer, g: integer, b: integer} with keys 'r', 'g', 'b' in [0,255] function H.decode_24bit_rgb(rgb_24bit) - vim.validate({ rgb_24bit = { rgb_24bit, "number", true } }) + if vim.fn.has("nvim-0.11") == 1 then + vim.validate("rgb_24bit", rgb_24bit, "number", true) + else + vim.validate({ rgb_24bit = { rgb_24bit, "number", true } }) + end local r = band(rshift(rgb_24bit, 16), 255) local g = band(rshift(rgb_24bit, 8), 255) local b = band(rgb_24bit, 255)