diff options
| author | Jongwook Choi <wookayin@gmail.com> | 2024-01-25 13:27:48 -0500 |
|---|---|---|
| committer | Lewis Russell <me@lewisr.dev> | 2024-02-08 12:40:16 +0000 |
| commit | 800134ea5ec60338a40280c8536db6a6a4a10249 (patch) | |
| tree | 695df1b799773453b362d7c941450e3f81c5a2e4 /runtime/doc | |
| parent | 8b21fe83daf5e04afda6a2edf91e9258530124d8 (diff) | |
| download | rneovim-800134ea5ec60338a40280c8536db6a6a4a10249.tar.gz rneovim-800134ea5ec60338a40280c8536db6a6a4a10249.tar.bz2 rneovim-800134ea5ec60338a40280c8536db6a6a4a10249.zip | |
refactor(treesitter): typing for Query, TSQuery, and TSQueryInfo
- `TSQuery`: userdata object for parsed query.
- `vim.treesitter.Query`: renamed from `Query`.
- Add a new field `lang`.
- `TSQueryInfo`:
- Move to `vim/treesitter/_meta.lua`, because C code owns it.
- Correct typing for `patterns`, should be a map from `integer`
(pattern_id) to `(integer|string)[][]` (list of predicates or
directives).
- `vim.treesitter.QueryInfo` is added.
- This currently has the same structure as `TSQueryInfo` (exported
from C code).
- Document the fields (see `TSQuery:inspect`).
- Add typing for `vim._ts_parse_query()`.
Diffstat (limited to 'runtime/doc')
| -rw-r--r-- | runtime/doc/treesitter.txt | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 2755cd421b..1402753f15 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -976,7 +976,8 @@ get({lang}, {query_name}) *vim.treesitter.query.get()* • {query_name} (`string`) Name of the query (e.g. "highlights") Return: ~ - (`Query?`) Parsed query + (`vim.treesitter.Query?`) Parsed query. `nil` if no query files are + found. *vim.treesitter.query.get_files()* get_files({lang}, {query_name}, {is_included}) @@ -1040,12 +1041,12 @@ parse({lang}, {query}) *vim.treesitter.query.parse()* read the contents into a string before calling). Returns a `Query` (see |lua-treesitter-query|) object which can be used to - search nodes in the syntax tree for the patterns defined in {query} using `iter_*` methods - below. + search nodes in the syntax tree for the patterns defined in {query} using + the `iter_captures` and `iter_matches` methods. Exposes `info` and `captures` with additional context about {query}. • `captures` contains the list of unique capture names defined in {query}. - -`info.captures` also points to `captures`. + • `info.captures` also points to `captures`. • `info.patterns` contains information about predicates. Parameters: ~ @@ -1053,7 +1054,10 @@ parse({lang}, {query}) *vim.treesitter.query.parse()* • {query} (`string`) Query in s-expr syntax Return: ~ - (`Query`) Parsed query + (`vim.treesitter.Query`) Parsed query + + See also: ~ + • |vim.treesitter.query.get()| *Query:iter_captures()* Query:iter_captures({node}, {source}, {start}, {stop}) |