From ec8922978eb14fe62671628bb25215743712eac0 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sat, 1 Mar 2025 15:51:09 +0000 Subject: feat(treesitter): add more metadata to `language.inspect()` (#32657) Problem: No way to check the version of a treesitter parser. Solution: Add version metadata (ABI 15 parsers only) as well as parser state count and supertype information (ABI 15) in `vim.treesitter.language.inspect()`. Also graduate the `abi_version` field, as this is now the official upstream name. --------- Co-authored-by: Christian Clason --- runtime/doc/news.txt | 2 ++ runtime/doc/treesitter.txt | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'runtime/doc') diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 0d47c7adb9..b9c1e55305 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -409,6 +409,8 @@ TREESITTER • |:InspectTree| now shows which nodes are missing. • Bundled markdown highlight queries use `conceal_lines` metadata to conceal code block fence lines vertically. +• |vim.treesitter.language.inspect()| shows additional information, including + parser version for ABI 15 parsers. TUI diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 8c63f0b5db..5916ec9371 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -1192,14 +1192,17 @@ get_lang({filetype}) *vim.treesitter.language.get_lang()* inspect({lang}) *vim.treesitter.language.inspect()* Inspects the provided language. - Inspecting provides some useful information on the language like node and - field names, ABI version, and whether the language came from a WASM - module. + Inspecting provides some useful information on the language like ABI + version, parser state count (a measure of parser complexity), node and + field names, and whether the language came from a WASM module. Node names are returned in a table mapping each node name to a `boolean` indicating whether or not the node is named (i.e., not anonymous). Anonymous nodes are surrounded with double quotes (`"`). + For ABI 15 parsers, also show parser metadata (major, minor, patch + version) and a table of supertypes with their respective subtypes. + Parameters: ~ • {lang} (`string`) Language -- cgit