Variable: treesit-simple-indent-rules
treesit-simple-indent-rules is a buffer-local variable defined in
treesit.el.gz.
Documentation
A list of indent rule settings.
Each indent rule setting should be (LANGUAGE RULE...), where LANGUAGE is a language symbol, and each RULE is of the form
(MATCHER ANCHOR OFFSET)
MATCHER determines whether this rule applies, ANCHOR and OFFSET together determines which column to indent to.
A MATCHER is a function that takes three arguments (NODE PARENT BOL). BOL is the point where we are indenting: the beginning of line content, the position of the first non-whitespace character. NODE is the largest (highest-in-tree) node starting at that point. PARENT is the parent of NODE.
If MATCHER returns non-nil, meaning the rule matches, Emacs then uses ANCHOR to find an anchor, it should be a function that takes the same argument (NODE PARENT BOL) and returns a point.
Finally Emacs computes the column of that point returned by ANCHOR and adds OFFSET to it, and indents to that column. OFFSET can be an integer or a variable whose value is an integer.
For MATCHER and ANCHOR, Emacs provides some convenient presets.
See treesit-simple-indent-presets.
For complex cases, a RULE can also be a single function. This function should take the same argument as MATCHER or ANCHOR. If it matches, return a cons (ANCHOR-POS . OFFSET), where ANCHOR-POS is a position and OFFSET is the indent offset; if it doesn't match, return nil.
Source Code
;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defvar-local treesit-simple-indent-rules nil
"A list of indent rule settings.
Each indent rule setting should be (LANGUAGE RULE...), where LANGUAGE is
a language symbol, and each RULE is of the form
(MATCHER ANCHOR OFFSET)
MATCHER determines whether this rule applies, ANCHOR and
OFFSET together determines which column to indent to.
A MATCHER is a function that takes three arguments (NODE PARENT
BOL). BOL is the point where we are indenting: the beginning of
line content, the position of the first non-whitespace character.
NODE is the largest (highest-in-tree) node starting at that
point. PARENT is the parent of NODE.
If MATCHER returns non-nil, meaning the rule matches, Emacs then
uses ANCHOR to find an anchor, it should be a function that takes
the same argument (NODE PARENT BOL) and returns a point.
Finally Emacs computes the column of that point returned by
ANCHOR and adds OFFSET to it, and indents to that column. OFFSET
can be an integer or a variable whose value is an integer.
For MATCHER and ANCHOR, Emacs provides some convenient presets.
See `treesit-simple-indent-presets'.
For complex cases, a RULE can also be a single function. This function
should take the same argument as MATCHER or ANCHOR. If it matches,
return a cons (ANCHOR-POS . OFFSET), where ANCHOR-POS is a position and
OFFSET is the indent offset; if it doesn't match, return nil.")