Skip to content

Commit 23532cf

Browse files
refactor: migrate nvim <table> deprecations to <params> (#3047)
1 parent 57a1239 commit 23532cf

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

lua/codecompanion/utils/log.lua

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ for k, v in pairs(vim.log.levels) do
1111
end
1212

1313
function LogHandler.new(opts)
14-
vim.validate({
15-
type = { opts.type, "string" },
16-
handle = { opts.handle, "function" },
17-
formatter = { opts.formatter, "function" },
18-
level = { opts.level, "number", true },
19-
})
14+
vim.validate("type", opts.type, "string")
15+
vim.validate("handle", opts.handle, "function")
16+
vim.validate("formatter", opts.formatter, "function")
17+
vim.validate("level", opts.level, "number", true)
2018
return setmetatable({
2119
type = opts.type,
2220
handle = opts.handle,
@@ -55,9 +53,7 @@ end
5553
---@return CodeCompanion.LogHandler
5654
local function create_file_handler(opts)
5755
local a = require("plenary.async")
58-
vim.validate({
59-
filename = { opts.filename, "string" },
60-
})
56+
vim.validate("filename", opts.filename, "string")
6157
local ok, stdpath = pcall(vim.fn.stdpath, "log")
6258
if not ok then
6359
stdpath = vim.fn.stdpath("cache")
@@ -152,9 +148,7 @@ end
152148
---@param opts table
153149
---@return CodeCompanion.LogHandler
154150
local function create_handler(opts)
155-
vim.validate({
156-
type = { opts.type, "string" },
157-
})
151+
vim.validate("type", opts.type, "string")
158152
if not opts.formatter then
159153
opts.formatter = default_formatter
160154
end
@@ -180,10 +174,8 @@ local Logger = {}
180174

181175
---@param opts CodeCompanion.LoggerArgs
182176
function Logger.new(opts)
183-
vim.validate({
184-
handlers = { opts.handlers, "table" },
185-
level = { opts.level, "number", true },
186-
})
177+
vim.validate("handlers", opts.handlers, "table")
178+
vim.validate("level", opts.level, "number", true)
187179
local handlers = {}
188180
for _, defn in ipairs(opts.handlers) do
189181
table.insert(handlers, create_handler(defn))

0 commit comments

Comments
 (0)