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 (car (car treesit-range-settings))))
        (if (treesit-query-p query)
            (treesit-parser-create
             (treesit-query-language query))
          (car (treesit-parser-list))))
    (car (treesit-parser-list))))