aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/treesit.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/treesit.el')
-rw-r--r--lisp/treesit.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 3539942f19a..2acb46ab105 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1589,6 +1589,14 @@ should take the same argument as MATCHER or ANCHOR. If it matches,
1589return a cons (ANCHOR-POS . OFFSET), where ANCHOR-POS is a position and 1589return a cons (ANCHOR-POS . OFFSET), where ANCHOR-POS is a position and
1590OFFSET is the indent offset; if it doesn't match, return nil.") 1590OFFSET is the indent offset; if it doesn't match, return nil.")
1591 1591
1592(defun treesit--indent-prev-line-node (pos)
1593 "Return the largest node on the previous line of POS."
1594 (save-excursion
1595 (goto-char pos)
1596 (when (eq (forward-line -1) 0)
1597 (back-to-indentation)
1598 (treesit--indent-largest-node-at (point)))))
1599
1592(defvar treesit-simple-indent-presets 1600(defvar treesit-simple-indent-presets
1593 (list (cons 'match 1601 (list (cons 'match
1594 (lambda 1602 (lambda
@@ -1639,6 +1647,12 @@ OFFSET is the indent offset; if it doesn't match, return nil.")
1639 (lambda (node &rest _) 1647 (lambda (node &rest _)
1640 (string-match-p 1648 (string-match-p
1641 type (or (treesit-node-type node) ""))))) 1649 type (or (treesit-node-type node) "")))))
1650 ;; FIXME: Add to manual.
1651 (cons 'prev-line-is (lambda (type)
1652 (lambda (_n _p bol &rest _)
1653 (treesit-node-match-p
1654 (treesit--indent-prev-line-node bol)
1655 type))))
1642 (cons 'field-is (lambda (name) 1656 (cons 'field-is (lambda (name)
1643 (lambda (node &rest _) 1657 (lambda (node &rest _)
1644 (string-match-p 1658 (string-match-p