@@ -617,15 +617,29 @@ See `treesit-simple-indent-rules'."
617
617
(rx (and " ->" (? " >" ) line-end)))
618
618
" A regular expression matching a threading macro." )
619
619
620
- (defun clojure-ts--threading-macro-p (node )
621
- " Return non-nil if NODE is a threading macro symbol like ->>."
622
- (clojure-ts--symbol-matches-p clojure-ts--threading-macro node))
620
+ (defun clojure-ts--match-threading-macro-arg (_node parent _ )
621
+ " Match NODE if it is an argument to a PARENT threading macro."
622
+ ; ; We want threading macros to indent 2 only if the ->> is on it's own line.
623
+ ; ; If not, then align functoin arg.
624
+ (and (clojure-ts--list-node-p parent)
625
+ (let ((first-child (treesit-node-child parent 0 t )))
626
+ (clojure-ts--symbol-matches-p
627
+ clojure-ts--threading-macro
628
+ first-child))))
629
+
630
+ (defun clojure-ts--threading-macro-arg-offset (node _parent _bol )
631
+ " Calculates the indentation offset for NODE, a threading macro argument."
632
+ (if (and node (<= (treesit-node-index node t ) 1 ))
633
+ 1 ; ; NODE is the first arg, offset 1 from start of *->> symbol
634
+ 0 )) ; ; arg 2...n, match indentation of the previous argument
623
635
624
636
(defvar clojure-ts--semantic-indent-rules
625
637
`((clojure
626
638
((parent-is " source" ) parent-bol 0 )
627
639
; ; https://guide.clojure.style/#body-indentation
628
640
(clojure-ts--match-expression-in-body parent 2 )
641
+ ; ; https://guide.clojure.style/#threading-macros-alignment
642
+ (clojure-ts--match-threading-macro-arg prev-sibling 0 )
629
643
; ; https://guide.clojure.style/#vertically-align-fn-args
630
644
(clojure-ts--match-function-call-arg (nth-sibling 2 nil ) 0 )
631
645
; ; Literal Sequences
0 commit comments