diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-05-11 11:13:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-11 11:13:32 +0100 |
commit | af040c3a079f6e25db0ad6b908aa1327f67deb82 (patch) | |
tree | e5d90fd09f0c0cfcb99afb6ca7b564ba98fd31f0 /runtime/lua/vim/treesitter/query.lua | |
parent | e90b506903babc84f8c5b796c3b25c7f20e183d2 (diff) | |
download | rneovim-af040c3a079f6e25db0ad6b908aa1327f67deb82.tar.gz rneovim-af040c3a079f6e25db0ad6b908aa1327f67deb82.tar.bz2 rneovim-af040c3a079f6e25db0ad6b908aa1327f67deb82.zip |
feat(treesitter): add support for setting query depths
Diffstat (limited to 'runtime/lua/vim/treesitter/query.lua')
-rw-r--r-- | runtime/lua/vim/treesitter/query.lua | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua index 93841bb31e..e6a117557a 100644 --- a/runtime/lua/vim/treesitter/query.lua +++ b/runtime/lua/vim/treesitter/query.lua @@ -686,16 +686,20 @@ end ---@param source (integer|string) Source buffer or string to search ---@param start integer Starting line for the search ---@param stop integer Stopping line for the search (end-exclusive) +---@param opts table|nil Options: +--- - max_start_depth (integer) if non-zero, sets the maximum start depth +--- for each match. This is used to prevent traversing too deep into a tree. +--- Requires treesitter >= 0.20.9. --- ---@return (fun(): integer, table<integer,TSNode>, table): pattern id, match, metadata -function Query:iter_matches(node, source, start, stop) +function Query:iter_matches(node, source, start, stop, opts) if type(source) == 'number' and source == 0 then source = api.nvim_get_current_buf() end start, stop = value_or_node_range(start, stop, node) - local raw_iter = node:_rawquery(self.query, false, start, stop) + local raw_iter = node:_rawquery(self.query, false, start, stop, opts) ---@cast raw_iter fun(): string, any local function iter() local pattern, match = raw_iter() |