docs(treesitter): expose LanguageTree:parent() #32108

Plugins may want to climb up the LanguageTree.

Also add missing type annotations for other methods.
This commit is contained in:
Jaehwang Jung
2025-01-20 21:17:36 +09:00
committed by GitHub
parent 71922cd1dc
commit 27c8806953
2 changed files with 20 additions and 1 deletions

View File

@@ -267,6 +267,7 @@ function LanguageTree:trees()
end
--- Gets the language of this tree node.
--- @return string
function LanguageTree:lang()
return self._lang
end
@@ -307,11 +308,13 @@ function LanguageTree:is_valid(exclude_children)
end
--- Returns a map of language to child tree.
--- @return table<string,vim.treesitter.LanguageTree>
function LanguageTree:children()
return self._children
end
--- Returns the source content of the language tree (bufnr or string).
--- @return integer|string
function LanguageTree:source()
return self._source
end
@@ -630,7 +633,8 @@ function LanguageTree:add_child(lang)
return self._children[lang]
end
--- @package
---Returns the parent tree. `nil` for the root tree.
---@return vim.treesitter.LanguageTree?
function LanguageTree:parent()
return self._parent
end