aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/news.txt2
-rw-r--r--runtime/doc/treesitter.txt9
-rw-r--r--runtime/lua/vim/treesitter/_meta/misc.lua7
-rw-r--r--runtime/lua/vim/treesitter/health.lua2
-rw-r--r--runtime/lua/vim/treesitter/language.lua8
5 files changed, 21 insertions, 7 deletions
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
diff --git a/runtime/lua/vim/treesitter/_meta/misc.lua b/runtime/lua/vim/treesitter/_meta/misc.lua
index c532257f49..99267bb36e 100644
--- a/runtime/lua/vim/treesitter/_meta/misc.lua
+++ b/runtime/lua/vim/treesitter/_meta/misc.lua
@@ -22,10 +22,15 @@ error('Cannot require a meta file')
---@field patterns table<integer, (integer|string)[][]>
---
---@class TSLangInfo
+---@field abi_version integer
+---@field major_version? integer
+---@field minor_version? integer
+---@field patch_version? integer
+---@field state_count integer
---@field fields string[]
---@field symbols table<string,boolean>
+---@field supertypes table<string,string[]>
---@field _wasm boolean
----@field _abi_version integer
--- @param lang string
--- @return TSLangInfo
diff --git a/runtime/lua/vim/treesitter/health.lua b/runtime/lua/vim/treesitter/health.lua
index 53b64d1dec..0c9e210fc1 100644
--- a/runtime/lua/vim/treesitter/health.lua
+++ b/runtime/lua/vim/treesitter/health.lua
@@ -35,7 +35,7 @@ function M.check()
else
local lang = ts.language.inspect(parsername)
health.ok(
- string.format('Parser: %-20s ABI: %d, path: %s', parsername, lang._abi_version, parser)
+ string.format('Parser: %-20s ABI: %d, path: %s', parsername, lang.abi_version, parser)
)
end
end
diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua
index 38d309a102..f70f99421c 100644
--- a/runtime/lua/vim/treesitter/language.lua
+++ b/runtime/lua/vim/treesitter/language.lua
@@ -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)