@@ -615,6 +615,26 @@ See `treesit-simple-indent-rules'."
615
615
clojure-ts--symbols-with-body-expressions-regexp
616
616
first-child)))))
617
617
618
+ (defconst clojure-ts--reifying-symbol-regexp
619
+ (eval-and-compile
620
+ (rx line-start
621
+ (or " deftype" " defrecord"
622
+ " reify" " proxy" " extend-type" " extend-protocol" )))
623
+ " A regular expression matching a symbol used to define a concrete type." )
624
+
625
+ (defun clojure-ts--match-method-body (node parent _bol )
626
+ " Matches a `NODE' in the body of a `PARENT' method implementation.
627
+ A method implementation referes to concrete implemntations being defined in
628
+ forms like deftype, defrecord, reify, proxy, etc."
629
+ (and
630
+ (clojure-ts--list-node-p parent)
631
+ (let* ((grandparent (treesit-node-parent parent))
632
+ ; ; auncle: gender neutral sibling of parent, aka child of grandparent
633
+ (first-auncle (treesit-node-child grandparent 0 t )))
634
+ (and (clojure-ts--list-node-p grandparent)
635
+ (clojure-ts--symbol-matches-p clojure-ts--reifying-symbol-regexp
636
+ first-auncle)))))
637
+
618
638
(defvar clojure-ts--threading-macro
619
639
(eval-and-compile
620
640
(rx (and " ->" (? " >" ) line-end)))
@@ -623,7 +643,7 @@ See `treesit-simple-indent-rules'."
623
643
(defun clojure-ts--match-threading-macro-arg (_node parent _ )
624
644
" Match NODE if it is an argument to a PARENT threading macro."
625
645
; ; We want threading macros to indent 2 only if the ->> is on it's own line.
626
- ; ; If not, then align functoin arg.
646
+ ; ; If not, then align function arg.
627
647
(and (clojure-ts--list-node-p parent)
628
648
(let ((first-child (treesit-node-child parent 0 t )))
629
649
(clojure-ts--symbol-matches-p
@@ -640,6 +660,7 @@ See `treesit-simple-indent-rules'."
640
660
`((clojure
641
661
((parent-is " source" ) parent-bol 0 )
642
662
; ; https://guide.clojure.style/#body-indentation
663
+ (clojure-ts--match-method-body parent 2 )
643
664
(clojure-ts--match-expression-in-body parent 2 )
644
665
; ; https://guide.clojure.style/#threading-macros-alignment
645
666
(clojure-ts--match-threading-macro-arg prev-sibling 0 )
@@ -654,7 +675,7 @@ See `treesit-simple-indent-rules'."
654
675
(defun clojure-ts--configured-indent-rules ()
655
676
" Gets the configured choice of indent rules."
656
677
(cond
657
- ((eq clojure-ts-indent-style 'semantic ) clojure-ts--semantic-indent-rules)
678
+ ((eq clojure-ts-indent-style 'semantic ) ( clojure-ts--semantic-indent-rules) )
658
679
((eq clojure-ts-indent-style 'fixed ) clojure-ts--fixed-indent-rules)
659
680
(t (error
660
681
(format
0 commit comments