mirror of
https://github.com/neovim/neovim.git
synced 2025-09-09 04:48:18 +00:00
treesitter: use lua-match? instead of match?
This commit is contained in:

committed by
Björn Linse

parent
e57ea5f2a9
commit
2d6437f5fb
@@ -60,7 +60,7 @@ local predicate_handlers = {
|
|||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["match?"] = function(match, _, bufnr, predicate)
|
["lua-match?"] = function(match, _, bufnr, predicate)
|
||||||
local node = match[predicate[2]]
|
local node = match[predicate[2]]
|
||||||
local regex = predicate[3]
|
local regex = predicate[3]
|
||||||
local start_row, _, end_row, _ = node:range()
|
local start_row, _, end_row, _ = node:range()
|
||||||
@@ -71,7 +71,7 @@ local predicate_handlers = {
|
|||||||
return string.find(M.get_node_text(node, bufnr), regex)
|
return string.find(M.get_node_text(node, bufnr), regex)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["vim-match?"] = (function()
|
["match?"] = (function()
|
||||||
local magic_prefixes = {['\\v']=true, ['\\m']=true, ['\\M']=true, ['\\V']=true}
|
local magic_prefixes = {['\\v']=true, ['\\m']=true, ['\\M']=true, ['\\V']=true}
|
||||||
local function check_magic(str)
|
local function check_magic(str)
|
||||||
if string.len(str) < 2 or magic_prefixes[string.sub(str,1,2)] then
|
if string.len(str) < 2 or magic_prefixes[string.sub(str,1,2)] then
|
||||||
@@ -114,6 +114,9 @@ local predicate_handlers = {
|
|||||||
end
|
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
|
--- Adds a new predicates to be used in queries
|
||||||
--
|
--
|
||||||
-- @param name the name of the predicate, without leading #
|
-- @param name the name of the predicate, without leading #
|
||||||
|
Reference in New Issue
Block a user