Skip to content

Commit ce90a9b

Browse files
committed
Don't indent toplevel defs with metadata
1 parent 9112b4d commit ce90a9b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clojure-ts-mode.el

+8
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,13 @@ forms like deftype, defrecord, reify, proxy, etc."
810810
(clojure-ts--match-fn-docstring parent)
811811
(clojure-ts--match-method-docstring parent))))
812812

813+
(defun clojure-ts--match-toplevel-with-meta (node parent _bol)
814+
"Match NODE when it is toplevel form and it has metadata"
815+
(let* ((grandparent (treesit-node-parent parent)))
816+
(and (string-equal "source" (treesit-node-type grandparent))
817+
(clojure-ts--list-node-p parent)
818+
(treesit-node-child-by-field-name parent "meta"))))
819+
813820
(defun clojure-ts--semantic-indent-rules ()
814821
"Return a list of indentation rules for `treesit-simple-indent-rules'."
815822
`((clojure
@@ -822,6 +829,7 @@ forms like deftype, defrecord, reify, proxy, etc."
822829
(clojure-ts--match-threading-macro-arg prev-sibling 0)
823830
;; https://guide.clojure.style/#vertically-align-fn-args
824831
(clojure-ts--match-function-call-arg (nth-sibling 2 nil) 0)
832+
(clojure-ts--match-toplevel-with-meta parent 0)
825833
;; Literal Sequences
826834
((parent-is "list_lit") parent 1) ;; https://guide.clojure.style/#one-space-indent
827835
((parent-is "vec_lit") parent 1) ;; https://guide.clojure.style/#bindings-alignment

0 commit comments

Comments
 (0)