Variable: treesit-indent-function
treesit-indent-function is a variable defined in treesit.el.gz.
Value
treesit-simple-indent
Documentation
Function used by treesit-indent to do some of the work.
This function is called with
(NODE PARENT BOL &rest _)
and returns
(ANCHOR . OFFSET).
BOL is the position of the beginning of the line; NODE is the
"largest" node that starts at BOL (and isn't a root node);
PARENT is its parent; ANCHOR is a point (not a node), and OFFSET
is a number. Emacs finds the column of ANCHOR and adds OFFSET to
it as the final indentation of the current line.
Source Code
;; Defined in /usr/src/emacs/lisp/treesit.el.gz
;; This variable might seem unnecessary: why split
;; `treesit-indent' and `treesit-simple-indent' into two
;; functions? We add this variable in between because later we might
;; add more powerful indentation engines, and that new engine can
;; probably share `treesit-indent'. It is also useful, suggested
;; by Stefan M, to have a function that figures out how much to indent
;; but doesn't actually performs the indentation, because we might
;; want to know where will a node indent to if we put it at some other
;; location, and use that information to calculate the actual
;; indentation. And `treesit-simple-indent' is that function. I
;; forgot the example Stefan gave, but it makes a lot of sense.
(defvar treesit-indent-function #'treesit-simple-indent
"Function used by `treesit-indent' to do some of the work.
This function is called with
(NODE PARENT BOL &rest _)
and returns
(ANCHOR . OFFSET).
BOL is the position of the beginning of the line; NODE is the
\"largest\" node that starts at BOL (and isn't a root node);
PARENT is its parent; ANCHOR is a point (not a node), and OFFSET
is a number. Emacs finds the column of ANCHOR and adds OFFSET to
it as the final indentation of the current line.")