@@ -608,6 +608,12 @@ with the markdown_inline grammar."
608
608
This does not include the NODE's namespace."
609
609
(treesit-node-text (treesit-node-child-by-field-name node " name" )))
610
610
611
+ (defun clojure-ts--node-namespace-text (node )
612
+ " Gets the namespace of a symbol or keyword NODE.
613
+
614
+ If there is no namespace, returns nil."
615
+ (treesit-node-text (treesit-node-child-by-field-name node " namespace" )))
616
+
611
617
(defun clojure-ts--symbol-named-p (expected-symbol-name node )
612
618
" Return non-nil if NODE is a symbol with text matching EXPECTED-SYMBOL-NAME."
613
619
(and (clojure-ts--symbol-node-p node)
@@ -909,7 +915,7 @@ and (:defn) is converted to (:inner 1)."
909
915
((equal spec :defn ) (list :inner current-depth))
910
916
(t nil ))))
911
917
912
- (defun clojure-ts--dynamic-indent-for-symbol (symbol-name )
918
+ (defun clojure-ts--dynamic-indent-for-symbol (symbol-name symbol-namespace )
913
919
" Returns the dynamic indentation specification for SYMBOL-NAME, if found.
914
920
915
921
If the function `clojure-ts-get-indent-function' is defined, call it and
@@ -919,9 +925,15 @@ The `clojure-ts-get-indent-function' should return an indentation
919
925
specification compatible with `clojure-mode' , which will then be
920
926
converted to a suitable `clojure-ts-mode' specification.
921
927
922
- For example, (1 ((:defn)) nil) is converted to ((:block 1) (:inner 2))."
928
+ For example, (1 ((:defn)) nil) is converted to ((:block 1) (:inner 2)).
929
+
930
+ If SYMBOL-NAMESPACE is defined, then the fully qualified symbol is
931
+ passed to `clojure-ts-get-indent-function' ."
923
932
(when (functionp clojure-ts-get-indent-function)
924
- (let ((spec (funcall clojure-ts-get-indent-function symbol-name)))
933
+ (let* ((full-symbol (if symbol-namespace
934
+ (concat symbol-namespace " /" symbol-name)
935
+ symbol-name))
936
+ (spec (funcall clojure-ts-get-indent-function full-symbol)))
925
937
(if (integerp spec)
926
938
(list (list :block spec))
927
939
(when (sequencep spec)
@@ -948,8 +960,9 @@ root of the syntax tree, it returns nil. A rule is considered a match
948
960
only if the CURRENT-DEPTH matches the rule's required depth."
949
961
(let* ((first-child (clojure-ts--node-child-skip-metadata parent 0 ))
950
962
(symbol-name (clojure-ts--named-node-text first-child))
963
+ (symbol-namespace (clojure-ts--node-namespace-text first-child))
951
964
(idx (- (treesit-node-index node) 2 )))
952
- (if-let* ((rule-set (or (clojure-ts--dynamic-indent-for-symbol symbol-name)
965
+ (if-let* ((rule-set (or (clojure-ts--dynamic-indent-for-symbol symbol-name symbol-namespace )
953
966
(alist-get symbol-name
954
967
(seq-union clojure-ts-semantic-indent-rules
955
968
clojure-ts--semantic-indent-rules-defaults
0 commit comments