-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Use optimized validator if available
- Loading branch information
1 parent
bf65774
commit 630f997
Showing
8 changed files
with
46 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local M = {} | ||
|
||
--- Use the faster validate version if available | ||
-- Taken from: https://github.com/lukas-reineke/indent-blankline.nvim/pull/934/files#diff-09ebcaa8c75cd1e92d25640e377ab261cfecaf8351c9689173fd36c2d0c23d94R16 | ||
--- @param spec table<string,[any, vim.validate.Validator, boolean|string]> | ||
function M.validate(spec) | ||
if vim.fn.has('nvim-0.11') == 0 then | ||
return vim.validate(spec) | ||
end | ||
for key, key_spec in pairs(spec) do | ||
local message = type(key_spec[3]) == 'string' and key_spec[3] or nil --[[@as string?]] | ||
local optional = type(key_spec[3]) == 'boolean' and key_spec[3] or nil --[[@as boolean?]] | ||
---@diagnostic disable-next-line:param-type-mismatch, redundant-parameter | ||
vim.validate(key, key_spec[1], key_spec[2], optional, message) | ||
end | ||
end | ||
|
||
return M |