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)
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 in the parser list, or create one if none exists.
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)
"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 in the
parser list, or create one if none exists."
(if-let ((parser
(if language
(treesit-parser-create language)
(or (car (treesit-parser-list))
(signal 'treesit-no-parser (list (current-buffer)))))))
(treesit-parser-root-node parser)))