aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter/query.lua
diff options
context:
space:
mode:
authorThomas Vigouroux <tomvig38@gmail.com>2020-07-16 17:17:42 +0200
committerThomas Vigouroux <tomvig38@gmail.com>2020-08-13 20:30:15 +0200
commit18c0e775286aa6621d9190db8cf02e65a3f3d61f (patch)
tree8a53b4e0c7dc4bf78a310878a61bac00a4da08a1 /runtime/lua/vim/treesitter/query.lua
parent613068071e02ddf5958fa82974373c370112c5e6 (diff)
downloadrneovim-18c0e775286aa6621d9190db8cf02e65a3f3d61f.tar.gz
rneovim-18c0e775286aa6621d9190db8cf02e65a3f3d61f.tar.bz2
rneovim-18c0e775286aa6621d9190db8cf02e65a3f3d61f.zip
treesitter(docs): update and refresh docs
Diffstat (limited to 'runtime/lua/vim/treesitter/query.lua')
-rw-r--r--runtime/lua/vim/treesitter/query.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua
index 914c266426..d16e1c3662 100644
--- a/runtime/lua/vim/treesitter/query.lua
+++ b/runtime/lua/vim/treesitter/query.lua
@@ -67,6 +67,11 @@ local predicate_handlers = {
end,
}
+--- Adds a new predicates to be used in queries
+--
+-- @param name the name of the predicate, without leading #
+-- @param handler the handler function to be used
+-- signature will be (match, pattern, bufnr, predicate)
function M.add_predicate(name, handler)
if predicate_handlers[name] then
a.nvim_err_writeln("It is recomended to not overwrite predicates.")
@@ -93,6 +98,15 @@ function Query:match_preds(match, pattern, bufnr)
return true
end
+--- Iterates of the captures of self on a given range.
+--
+-- @param node The node under witch the search will occur
+-- @param buffer The source buffer to search
+-- @param start The starting line of the search
+-- @param stop The stoping line of the search (end-exclusive)
+--
+-- @returns The matching capture id
+-- @returns The captured node
function Query:iter_captures(node, bufnr, start, stop)
if bufnr == 0 then
bufnr = vim.api.nvim_get_current_buf()
@@ -112,6 +126,15 @@ function Query:iter_captures(node, bufnr, start, stop)
return iter
end
+--- Iterates of the matches of self on a given range.
+--
+-- @param node The node under witch the search will occur
+-- @param buffer The source buffer to search
+-- @param start The starting line of the search
+-- @param stop The stoping line of the search (end-exclusive)
+--
+-- @returns The matching pattern id
+-- @returns The matching match
function Query:iter_matches(node, bufnr, start, stop)
if bufnr == 0 then
bufnr = vim.api.nvim_get_current_buf()