Function: treesit-buffer-root-node
treesit-buffer-root-node is a byte-compiled function defined in
treesit.el.gz.
Signature
(treesit-buffer-root-node &optional LANGUAGE TAG)
Documentation
Return the root node of the current buffer.
Use the first parser in the parser list if LANGUAGE is omitted.
If LANGUAGE is non-nil, use the first parser for LANGUAGE with TAG in the parser list, or create one if none exists. TAG defaults to nil.
Other relevant functions are documented in the treesit group.
Shortdoc
;; treesit
(treesit-buffer-root-node)
e.g. => #<treesit-node (translation_unit) in 1-4830>
Source Code
;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-buffer-root-node (&optional language tag)
"Return the root node of the current buffer.
Use the first parser in the parser list if LANGUAGE is omitted.
If LANGUAGE is non-nil, use the first parser for LANGUAGE with
TAG in the parser list, or create one if none exists. TAG
defaults to nil."
(if-let ((parser
(if language
(treesit-parser-create language nil nil tag)
(or (car (treesit-parser-list))
(signal 'treesit-no-parser (list (current-buffer)))))))
(treesit-parser-root-node parser)))