and the engine takes care of the rest.
To enable the parser-based indentation engine, either set
-@code{treesit-simple-indent-rules} and call
-@code{treesit-major-mode-setup}, or equivalently, set the value of
-@code{indent-line-function} to @code{treesit-indent}.
+@code{treesit-simple-indent-rules} or set
+@code{treesit-indent-function}, then call
+@code{treesit-major-mode-setup}. (All that
+@code{treesit-major-mode-setup} does is setting the value of
+@code{indent-line-function} to @code{treesit-indent} and
+@code{indent-region-function} to @code{treesit-indent-region}.)
@defvar treesit-indent-function
This variable stores the actual function called by
(when treesit-simple-indent-rules
(setq-local treesit-simple-indent-rules
(treesit--indent-rules-optimize
- treesit-simple-indent-rules))
+ treesit-simple-indent-rules)))
+ ;; Enable indent if simple indent rules are set, or the major mode
+ ;; sets a custom indent function.
+ (when (or treesit-simple-indent-rules
+ (and (not (eq treesit-indent-function #'treesit-simple-indent))
+ treesit-indent-function))
(setq-local indent-line-function #'treesit-indent)
(setq-local indent-region-function #'treesit-indent-region))
;; Navigation.