Skip to content

Commit ba6de87

Browse files
keskbbatsov
authored andcommitted
Fix indentation of namespaced maps in fixed style
Anchor collection node types in clojure-ts--fixed-indent-rules to avoid matching ns_map_lit, and add an explicit rule for ns_map_lit to ensure consistent indentation across styles.
1 parent e35f877 commit ba6de87

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## main (unreleased)
44

5+
- Fix indentation of namespaced maps in `fixed` indentation style.
56
- Add project root detection for ClojureCLR project.
67
- Add missing `defstruct` semantic indentation rule.
78
- Fix font-lock issues: duplicate query, missing `definline` metadata docstring.

clojure-ts-mode.el

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,10 +1219,11 @@ The possible values for this variable are
12191219
(let ((first-child (treesit-node-child parent 0 t)))
12201220
(clojure-ts--symbol-node-p first-child))))
12211221
parent 2)
1222-
((parent-is "vec_lit") parent 1)
1223-
((parent-is "map_lit") parent 1)
1224-
((parent-is "list_lit") parent 1)
1225-
((parent-is "set_lit") parent 2))))
1222+
((parent-is "^vec_lit$") parent 1)
1223+
((parent-is "^map_lit$") parent 1)
1224+
((parent-is "^list_lit$") parent 1)
1225+
((parent-is "^set_lit$") parent 2)
1226+
((parent-is "^ns_map_lit$") (nth-sibling 2) 1))))
12261227

12271228
(defvar clojure-ts--semantic-indent-rules-defaults
12281229
'(("alt!" . ((:block 0)))

test/clojure-ts-mode-indentation-test.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,12 @@ DESCRIPTION is a string with the description of the spec."
686686
[clojure.string :as str])
687687
(:import
688688
(java.util Date
689-
UUID)))"))
689+
UUID)))")
690+
691+
(when-indenting-fixed-it "should indent namespaced maps correctly"
692+
"
693+
#:foo{:bar 1
694+
:baz 2}"))
690695

691696
(describe "clojure-ts-align"
692697
(it "should handle improperly indented content"

0 commit comments

Comments
 (0)