Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions lua/screenkey/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ function M.tbl_contains(t, value, f)
return false
end

---@param opts table
---@param opts table<string, table>
---@param user_config table
---@param path string
---@return boolean, string?
function M.validate(opts, user_config, path)
local ok, err = pcall(vim.validate, opts)
if not ok then
return false, ("- %s: %s"):format(path, err)
local unpack = unpack or table.unpack
for k, v in pairs(opts) do
local ok, err = pcall(vim.validate, k, unpack(v))
if not ok then
return false, ("- %s: %s"):format(path, err)
end
end

local errors = {}
Expand All @@ -41,14 +44,17 @@ function M.validate(opts, user_config, path)
return false, table.concat(errors, "\n")
end

---@param opts table
---@param opts table<string, table>
---@param user_config table
---@param path string
---@return boolean, string?
function M.validate_keytable(opts, user_config, path)
local ok, err = pcall(vim.validate, opts)
if not ok then
return false, ("- %s: %s"):format(path, err)
local unpack = unpack or table.unpack
for k, v in pairs(opts) do
local ok, err = pcall(vim.validate, k, unpack(v))
if not ok then
return false, ("- %s: %s"):format(path, err)
end
end

local errors = {}
Expand Down
Loading