aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-10-18 11:33:12 +0100
committerLewis Russell <me@lewisr.dev>2024-10-21 11:32:06 +0100
commit3572319b4cb1a4163624a5fe328886f1928dbc4a (patch)
tree5e190a6d9ca8a2e0f998ef578f895efee9450fb4 /scripts
parent6fd13eeddaf5db89c1b81cc7d3d3f1a7da5401a7 (diff)
downloadrneovim-3572319b4cb1a4163624a5fe328886f1928dbc4a.tar.gz
rneovim-3572319b4cb1a4163624a5fe328886f1928dbc4a.tar.bz2
rneovim-3572319b4cb1a4163624a5fe328886f1928dbc4a.zip
feat(vim.validate): improve fast form and deprecate spec form
Problem: `vim.validate()` takes two forms when it only needs one. Solution: - Teach the fast form all the features of the spec form. - Deprecate the spec form. - General optimizations for both forms. - Add a `message` argument which can be used alongside or in place of the `optional` argument.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/bump_deps.lua6
-rw-r--r--scripts/gen_help_html.lua52
2 files changed, 18 insertions, 40 deletions
diff --git a/scripts/bump_deps.lua b/scripts/bump_deps.lua
index e332ef475f..ad71da5150 100755
--- a/scripts/bump_deps.lua
+++ b/scripts/bump_deps.lua
@@ -325,10 +325,8 @@ function M.commit(dependency_name, commit)
end
function M.version(dependency_name, version)
- vim.validate {
- dependency_name = { dependency_name, 's' },
- version = { version, 's' },
- }
+ vim.validate('dependency_name', dependency_name, 'string')
+ vim.validate('version', version, 'string')
local dependency = assert(get_dependency(dependency_name))
verify_cmakelists_committed()
local commit_sha = get_gh_commit_sha(dependency.repo, version)
diff --git a/scripts/gen_help_html.lua b/scripts/gen_help_html.lua
index b5dbce38f6..21d865309d 100644
--- a/scripts/gen_help_html.lua
+++ b/scripts/gen_help_html.lua
@@ -1289,25 +1289,15 @@ end
---
--- @return nvim.gen_help_html.gen_result result
function M.gen(help_dir, to_dir, include, commit, parser_path)
- vim.validate {
- help_dir = {
- help_dir,
- function(d)
- return vim.fn.isdirectory(vim.fs.normalize(d)) == 1
- end,
- 'valid directory',
- },
- to_dir = { to_dir, 's' },
- include = { include, 't', true },
- commit = { commit, 's', true },
- parser_path = {
- parser_path,
- function(f)
- return f == nil or vim.fn.filereadable(vim.fs.normalize(f)) == 1
- end,
- 'valid vimdoc.{so,dll} filepath',
- },
- }
+ vim.validate('help_dir', help_dir, function(d)
+ return vim.fn.isdirectory(vim.fs.normalize(d)) == 1
+ end, 'valid directory')
+ vim.validate('to_dir', to_dir, 'string')
+ vim.validate('include', include, 'table', true)
+ vim.validate('commit', commit, 'sring', true)
+ vim.validate('parser_path', parser_path, function(f)
+ return vim.fn.filereadable(vim.fs.normalize(f)) == 1
+ end, true, 'valid vimdoc.{so,dll} filepath')
local err_count = 0
local redirects_count = 0
@@ -1410,23 +1400,13 @@ end
---
--- @return nvim.gen_help_html.validate_result result
function M.validate(help_dir, include, parser_path)
- vim.validate {
- help_dir = {
- help_dir,
- function(d)
- return vim.fn.isdirectory(vim.fs.normalize(d)) == 1
- end,
- 'valid directory',
- },
- include = { include, 't', true },
- parser_path = {
- parser_path,
- function(f)
- return f == nil or vim.fn.filereadable(vim.fs.normalize(f)) == 1
- end,
- 'valid vimdoc.{so,dll} filepath',
- },
- }
+ vim.validate('help_dir', help_dir, function(d)
+ return vim.fn.isdirectory(vim.fs.normalize(d)) == 1
+ end, 'valid directory')
+ vim.validate('include', include, 'table', true)
+ vim.validate('parser_path', parser_path, function(f)
+ return vim.fn.filereadable(vim.fs.normalize(f)) == 1
+ end, true, 'valid vimdoc.{so,dll} filepath')
local err_count = 0 ---@type integer
local files_to_errors = {} ---@type table<string, string[]>
ensure_runtimepath()