treesitter: use lua-match? instead of match?

This commit is contained in:
Thomas Vigouroux 2020-09-01 11:48:15 +02:00 committed by Björn Linse
parent e57ea5f2a9
commit 2d6437f5fb

View File

@ -60,7 +60,7 @@ local predicate_handlers = {
return true
end,
["match?"] = function(match, _, bufnr, predicate)
["lua-match?"] = function(match, _, bufnr, predicate)
local node = match[predicate[2]]
local regex = predicate[3]
local start_row, _, end_row, _ = node:range()
@ -71,7 +71,7 @@ local predicate_handlers = {
return string.find(M.get_node_text(node, bufnr), regex)
end,
["vim-match?"] = (function()
["match?"] = (function()
local magic_prefixes = {['\\v']=true, ['\\m']=true, ['\\M']=true, ['\\V']=true}
local function check_magic(str)
if string.len(str) < 2 or magic_prefixes[string.sub(str,1,2)] then
@ -114,6 +114,9 @@ local predicate_handlers = {
end
}
-- As we provide lua-match? also expose vim-match?
predicate_handlers["vim-match?"] = predicate_handlers["match?"]
--- Adds a new predicates to be used in queries
--
-- @param name the name of the predicate, without leading #