mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +00:00
treesitter: add contains? predicate
This commit is contained in:
@@ -65,6 +65,19 @@ local predicate_handlers = {
|
||||
|
||||
return string.find(get_node_text(node, bufnr), regex)
|
||||
end,
|
||||
|
||||
["contains?"] = function(match, _, bufnr, predicate)
|
||||
local node = match[predicate[2]]
|
||||
local node_text = get_node_text(node, bufnr)
|
||||
|
||||
for i=3,#predicate do
|
||||
if string.find(node_text, predicate[i], 1, true) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
}
|
||||
|
||||
--- Adds a new predicates to be used in queries
|
||||
|
||||
Reference in New Issue
Block a user