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 <c.clason@uni-graz.at>
This commit is contained in:
Lewis Russell
2025-03-01 15:51:09 +00:00
committed by GitHub
parent 48e6147e64
commit ec8922978e
7 changed files with 104 additions and 36 deletions

View File

@@ -168,13 +168,17 @@ end
--- 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.
---
---@param lang string Language
---@return TSLangInfo
function M.inspect(lang)