aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter.lua
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 /runtime/lua/vim/treesitter.lua
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 'runtime/lua/vim/treesitter.lua')
-rw-r--r--runtime/lua/vim/treesitter.lua8
1 files changed, 3 insertions, 5 deletions
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua
index c24a732fe3..9f6dc53932 100644
--- a/runtime/lua/vim/treesitter.lua
+++ b/runtime/lua/vim/treesitter.lua
@@ -241,11 +241,9 @@ end
---
---@return boolean True if the {node} contains the {range}
function M.node_contains(node, range)
- vim.validate({
- -- allow a table so nodes can be mocked
- node = { node, { 'userdata', 'table' } },
- range = { range, M._range.validate, 'integer list with 4 or 6 elements' },
- })
+ -- allow a table so nodes can be mocked
+ vim.validate('node', node, { 'userdata', 'table' })
+ vim.validate('range', range, M._range.validate, 'integer list with 4 or 6 elements')
return M._range.contains({ node:range() }, range)
end