Debian Codegraph @

runtime/queries/clojure/indents.scm

raw symbols SCIP
1 ; If a list has 2 elements on the first line, align to the second element.
2 ; Exclude literals and special keywords that have different indentation rules.
3 (list_lit . (_) @first . (_) @anchor
4 (#same-line? @first @anchor)
5
6 (#not-kind-eq? @first "bool_lit")
7 (#not-kind-eq? @first "nil_lit")
8 (#not-kind-eq? @first "str_lit")
9 (#not-kind-eq? @first "num_lit")
10 (#not-kind-eq? @first "kwd_lit")
11 (#not-match? @first "^(def|defn|defn-|defmacro|defmethod|defmulti|defonce|defprotocol|deftype|defrecord|defstruct|definline|definterface|deftest|ns|let|letfn|binding|loop|for|doseq|dotimes|when-let|if-let|when-some|if-some|with-.*|fn)$")) @align
12
13 ; If the first element in a list is also a list and on a line by itself,
14 ; the outer list is aligned to it
15 (list_lit . (list_lit) @anchor .
16 ) @align
17
18 (list_lit . (list_lit) @anchor . (_) @second
19 (#not-same-line? @anchor @second)
20 ) @align
21
22 ; If the first element in a list is not a list and on a line by itself,
23 ; indent the list body by one level
24 (list_lit . (_) @first .
25 (#not-kind-eq? @first "bool_lit")
26 (#not-kind-eq? @first "nil_lit")
27 (#not-kind-eq? @first "str_lit")
28 (#not-kind-eq? @first "num_lit")
29 (#not-kind-eq? @first "kwd_lit")
30 (#not-match? @first "^(def|defn|defn-|defmacro|defmethod|defmulti|defonce|defprotocol|deftype|defrecord|defstruct|definline|definterface|deftest|ns|let|letfn|binding|loop|for|doseq|dotimes|when-let|if-let|when-some|if-some|with-.*|fn)$")) @indent
31
32 (list_lit . (_) @first . (_) @second
33 (#not-same-line? @first @second)
34 (#not-kind-eq? @first "bool_lit")
35 (#not-kind-eq? @first "nil_lit")
36 (#not-kind-eq? @first "str_lit")
37 (#not-kind-eq? @first "num_lit")
38 (#not-kind-eq? @first "kwd_lit")
39 (#not-match? @first "^(def|defn|defn-|defmacro|defmethod|defmulti|defonce|defprotocol|deftype|defrecord|defstruct|definline|definterface|deftest|ns|let|letfn|binding|loop|for|doseq|dotimes|when-let|if-let|when-some|if-some|with-.*|fn)$")) @indent
40
41 ; If the first element is a literal, align the list to it
42 (list_lit . [(bool_lit) (nil_lit) (str_lit) (num_lit) (kwd_lit)] @anchor
43 ) @align
44
45 ; Special indentation for def-like forms, let bindings, and other special forms
46 ; These forms typically have the body indented by one level after the name/bindings
47 (list_lit . (sym_lit) @first
48 (#match? @first "^(def|defn|defn-|defmacro|defmethod|defmulti|defonce|defprotocol|deftype|defrecord|defstruct|definline|definterface|deftest|ns|let|letfn|binding|loop|for|doseq|dotimes|when-let|if-let|when-some|if-some|with-.*|fn)$")) @indent
49
50 ; Align vector/map elements when first two are on same line (e.g., let bindings)
51 (vec_lit . (_) @anchor . (_) @second
52 (#same-line? @anchor @second)
53 ) @align
54
55 (map_lit . (_) @anchor . (_) @second
56 (#same-line? @anchor @second)
57 ) @align
58
59 ; Indent vectors, maps, and sets
60 [(vec_lit) (map_lit) (set_lit)] @indent