diff options
author | Riley Bruins <ribru17@hotmail.com> | 2024-09-19 13:08:22 -0700 |
---|---|---|
committer | Christian Clason <c.clason@uni-graz.at> | 2024-10-11 18:15:07 +0200 |
commit | d3193afc2559e7d84ed2d76664a650dc03b4c6ef (patch) | |
tree | cfa3e37e11d158713ae01a691e03853509317e39 /runtime/lua/vim/treesitter/language.lua | |
parent | 267c7525f738cdd6024c39da758e885c026ffaaa (diff) | |
download | rneovim-d3193afc2559e7d84ed2d76664a650dc03b4c6ef.tar.gz rneovim-d3193afc2559e7d84ed2d76664a650dc03b4c6ef.tar.bz2 rneovim-d3193afc2559e7d84ed2d76664a650dc03b4c6ef.zip |
fix(treesitter): remove duplicate symbol names in language.inspect()
**Problems:**
- `vim.treesitter.language.inspect()` returns duplicate
symbol names, sometimes up to 6 of one kind in the case of `markdown`
- The list-like `symbols` table can have holes and is thus not even a
valid msgpack table anyway, mentioned in a test
**Solution:** Return symbols as a map, rather than a list, where field
names are the names of the symbol. The boolean value associated with the
field encodes whether or not the symbol is named.
Note that anonymous nodes are surrounded with double quotes (`"`) to
prevent potential collisions with named counterparts that have the same
identifier.
Diffstat (limited to 'runtime/lua/vim/treesitter/language.lua')
-rw-r--r-- | runtime/lua/vim/treesitter/language.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua index 9f7807e036..aa1d38df97 100644 --- a/runtime/lua/vim/treesitter/language.lua +++ b/runtime/lua/vim/treesitter/language.lua @@ -170,7 +170,12 @@ end --- Inspects the provided language. --- ---- Inspecting provides some useful information on the language like node names, ... +--- Inspecting provides some useful information on the language like node and field names, ABI +--- version, 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 +--- (`"`). --- ---@param lang string Language ---@return table |