Improve treesit-major-mode-setup indentation setup (bug#71086)
* lisp/treesit.el (treesit-major-mode-setup): Setup indentation when treesit-indent-function is set. * doc/lispref/modes.texi (Parser-based Indentation): Fix manual.
This commit is contained in:
parent
45ba332add
commit
e153093f0a
2 changed files with 12 additions and 4 deletions
|
@ -5186,9 +5186,12 @@ below: then the major mode needs only write some indentation rules,
|
|||
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
|
||||
|
|
|
@ -3008,7 +3008,12 @@ before calling this function."
|
|||
(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.
|
||||
|
|
Loading…
Add table
Reference in a new issue