treesitter: add contains? predicate

This commit is contained in:
Thomas Vigouroux
2020-08-10 09:41:57 +02:00
parent 18c0e77528
commit 58e37d7df8
2 changed files with 30 additions and 18 deletions

View File

@@ -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