Function: treesit--guess-primary-parser
treesit--guess-primary-parser is a byte-compiled function defined in
treesit.el.gz.
Signature
(treesit--guess-primary-parser)
Documentation
Guess the primary parser of the current buffer and return it.
Normally in a tree-sitter major mode, there is a primary parser that parses the entire buffer (as opposed to embedded parsers which only parses part of the buffer). This function tries to find and return that parser.
Source Code
;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit--guess-primary-parser ()
"Guess the primary parser of the current buffer and return it.
Normally in a tree-sitter major mode, there is a primary parser that
parses the entire buffer (as opposed to embedded parsers which only
parses part of the buffer). This function tries to find and return that
parser."
(if treesit-range-settings
(let* ((query (caar treesit-range-settings))
(lang (treesit-query-language query)))
;; Major mode end-user won't see this signal since major mode
;; author surely will see it and correct it. Also, multi-lang
;; major mode's author should've seen the notice and set the
;; primary parser themselves.
(if (treesit-query-p query)
(or (car (treesit-parser-list nil lang))
(signal 'treesit-no-parser (list lang)))
(or (car (treesit-parser-list))
(signal 'treesit-no-parser nil))))
(car (treesit-parser-list))))