mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
refactor(treesitter): redesign query iterating
Problem: `TSNode:_rawquery()` is complicated, has known issues and the Lua and C code is awkwardly coupled (see logic with `active`). Solution: - Add `TSQueryCursor` and `TSQueryMatch` bindings. - Replace `TSNode:_rawquery()` with `TSQueryCursor:next_capture()` and `TSQueryCursor:next_match()` - Do more stuff in Lua - API for `Query:iter_captures()` and `Query:iter_matches()` remains the same. - `treesitter.c` no longer contains any logic related to predicates. - Add `match_limit` option to `iter_matches()`. Default is still 256.
This commit is contained in:

committed by
Lewis Russell

parent
16a416cb3c
commit
aca2048bcd
@@ -1909,6 +1909,9 @@ static void nlua_add_treesitter(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
||||
lua_pushcfunction(lstate, tslua_push_parser);
|
||||
lua_setfield(lstate, -2, "_create_ts_parser");
|
||||
|
||||
lua_pushcfunction(lstate, tslua_push_querycursor);
|
||||
lua_setfield(lstate, -2, "_create_ts_querycursor");
|
||||
|
||||
lua_pushcfunction(lstate, tslua_add_language);
|
||||
lua_setfield(lstate, -2, "_ts_add_language");
|
||||
|
||||
|
Reference in New Issue
Block a user