@@ -1412,36 +1412,37 @@ if NODE has metadata and its parent has type NODE-TYPE."
1412
1412
(defun clojure-ts--semantic-indent-rules ()
1413
1413
" Return a list of indentation rules for `treesit-simple-indent-rules' ."
1414
1414
`((clojure
1415
- ((parent-is " source" ) parent-bol 0 )
1415
+ ((parent-is " ^ source$ " ) parent-bol 0 )
1416
1416
(clojure-ts--match-docstring parent 0 )
1417
1417
; ; Collections items with metadata.
1418
1418
; ;
1419
1419
; ; This should be before `clojure-ts--match-with-metadata' , otherwise they
1420
1420
; ; will never be matched.
1421
- (,(clojure-ts--match-collection-item-with-metadata " vec_lit" ) grand-parent 1 )
1422
- (,(clojure-ts--match-collection-item-with-metadata " map_lit" ) grand-parent 1 )
1423
- (,(clojure-ts--match-collection-item-with-metadata " set_lit" ) grand-parent 2 )
1421
+ (,(clojure-ts--match-collection-item-with-metadata " ^ vec_lit$ " ) grand-parent 1 )
1422
+ (,(clojure-ts--match-collection-item-with-metadata " ^ map_lit$ " ) grand-parent 1 )
1423
+ (,(clojure-ts--match-collection-item-with-metadata " ^ set_lit$ " ) grand-parent 2 )
1424
1424
; ;
1425
1425
; ; If we enable this rule for lists, it will break many things.
1426
1426
; ; (,(clojure-ts--match-collection-item-with-metadata "list_lit") grand-parent 1)
1427
1427
; ;
1428
1428
; ; All other forms with metadata.
1429
1429
(clojure-ts--match-with-metadata parent 0 )
1430
1430
; ; Literal Sequences
1431
- ((parent-is " vec_lit" ) parent 1 ) ; ; https://guide.clojure.style/#bindings-alignment
1432
- ((parent-is " map_lit" ) parent 1 ) ; ; https://guide.clojure.style/#map-keys-alignment
1433
- ((parent-is " set_lit" ) parent 2 )
1434
- ((parent-is " splicing_read_cond_lit" ) parent 4 )
1435
- ((parent-is " read_cond_lit" ) parent 3 )
1436
- ((parent-is " tagged_or_ctor_lit" ) parent 0 )
1431
+ ((parent-is " ^vec_lit$" ) parent 1 ) ; ; https://guide.clojure.style/#bindings-alignment
1432
+ ((parent-is " ^map_lit$" ) parent 1 ) ; ; https://guide.clojure.style/#map-keys-alignment
1433
+ ((parent-is " ^set_lit$" ) parent 2 )
1434
+ ((parent-is " ^splicing_read_cond_lit$" ) parent 4 )
1435
+ ((parent-is " ^read_cond_lit$" ) parent 3 )
1436
+ ((parent-is " ^tagged_or_ctor_lit$" ) parent 0 )
1437
+ ((parent-is " ^ns_map_lit$" ) (nth-sibling 2 ) 1 )
1437
1438
; ; https://guide.clojure.style/#body-indentation
1438
1439
(clojure-ts--match-form-body clojure-ts--anchor-parent-opening-paren 2 )
1439
1440
; ; https://guide.clojure.style/#threading-macros-alignment
1440
1441
(clojure-ts--match-threading-macro-arg prev-sibling 0 )
1441
1442
; ; https://guide.clojure.style/#vertically-align-fn-args
1442
1443
(clojure-ts--match-function-call-arg ,(clojure-ts--anchor-nth-sibling 1 ) 0 )
1443
1444
; ; https://guide.clojure.style/#one-space-indent
1444
- ((parent-is " list_lit" ) parent 1 ))))
1445
+ ((parent-is " ^ list_lit$ " ) parent 1 ))))
1445
1446
1446
1447
(defun clojure-ts--configured-indent-rules ()
1447
1448
" Gets the configured choice of indent rules."
@@ -1640,6 +1641,7 @@ have changed."
1640
1641
(query (treesit-query-compile 'clojure
1641
1642
(append
1642
1643
`(((map_lit) @map)
1644
+ ((ns_map_lit) @ns-map)
1643
1645
((list_lit
1644
1646
((sym_lit) @sym
1645
1647
(:match ,(clojure-ts-symbol-regexp clojure-ts-align-binding-forms) @sym))
@@ -1686,6 +1688,10 @@ subsequent special arguments based on block indentation rules."
1686
1688
(goto-char (treesit-node-start node))
1687
1689
(when-let* ((cur-sexp (treesit-node-first-child-for-pos node (point ) t )))
1688
1690
(goto-char (treesit-node-start cur-sexp))
1691
+ ; ; For namespaced maps we need to skip the namespace, which is the first
1692
+ ; ; nested sexp.
1693
+ (when (equal sexp-type 'ns-map )
1694
+ (treesit-beginning-of-thing 'sexp -1 'nested ))
1689
1695
; ; For cond forms we need to skip first n + 1 nodes according to block
1690
1696
; ; indentation rules. First node to skip is the symbol itself.
1691
1697
(when (equal sexp-type 'cond )
0 commit comments