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 . RULES), where LANGUAGE is a language symbol, and RULES is a list of

    (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.

View in manual

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 . RULES),
where LANGUAGE is a language symbol, and RULES is a list of

    (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'.")