|
| 1 | +;; -------------------------------------------------- |
| 2 | +;; cljfmt.edn |
| 3 | +;; Code format configuration |
| 4 | +;; with example indent patterns from community projects |
| 5 | +;; -------------------------------------------------- |
| 6 | + |
| 7 | + |
| 8 | +{;; Clojure format |
| 9 | + ;; https://github.com/weavejester/cljfmt |
| 10 | + |
| 11 | + :cljfmt |
| 12 | + {;; correct indentation - see cljfm indents |
| 13 | + :indentation? true |
| 14 | + |
| 15 | + ;; remove whitespace surrounding inner forms |
| 16 | + :remove-surrounding-whitespace? true |
| 17 | + |
| 18 | + ;; remove trailing whitespace in lines |
| 19 | + :remove-trailing-whitespace? true |
| 20 | + |
| 21 | + ;; insert whitespace missing from between elements |
| 22 | + :insert-missing-whitespace? true |
| 23 | + |
| 24 | + ;; Delete more than one consecutive blank line - annoying |
| 25 | + :remove-consecutive-blank-lines? false |
| 26 | + |
| 27 | + ;; Remove spaces not used for indentation |
| 28 | + :remove-multiple-non-indenting-spaces? true |
| 29 | + |
| 30 | + ;; break hashmaps onto multiple lines |
| 31 | + :split-keypairs-over-multiple-lines? true |
| 32 | + |
| 33 | + ;; Use #re for regex indents configuration |
| 34 | + ;; :cljfmt {:indents {#re ".*" ns [[:inner 0] [:inner 1]]}} |
| 35 | + :indents {}}} |
| 36 | + |
| 37 | +;; -------------------------------------------------- |
| 38 | +;; Example Indent rules - to review |
| 39 | + |
| 40 | +;; From https://github.com/weavejester/cljfmt |
| 41 | + |
| 42 | +;; Clojure.core |
| 43 | + |
| 44 | +#_ |
| 45 | +{alt! [[:block 0]] |
| 46 | + alt!! [[:block 0]] |
| 47 | + are [[:block 2]] |
| 48 | + as-> [[:block 2]] |
| 49 | + binding [[:block 1]] |
| 50 | + bound-fn [[:inner 0]] |
| 51 | + case [[:block 1]] |
| 52 | + catch [[:block 2]] |
| 53 | + comment [[:block 0]] |
| 54 | + cond [[:block 0]] |
| 55 | + condp [[:block 2]] |
| 56 | + cond-> [[:block 1]] |
| 57 | + cond->> [[:block 1]] |
| 58 | + def [[:inner 0]] |
| 59 | + defmacro [[:inner 0]] |
| 60 | + defmethod [[:inner 0]] |
| 61 | + defmulti [[:inner 0]] |
| 62 | + defn [[:inner 0]] |
| 63 | + defn- [[:inner 0]] |
| 64 | + defonce [[:inner 0]] |
| 65 | + defprotocol [[:block 1] [:inner 1]] |
| 66 | + defrecord [[:block 2] [:inner 1]] |
| 67 | + defstruct [[:block 1]] |
| 68 | + deftest [[:inner 0]] |
| 69 | + deftype [[:block 2] [:inner 1]] |
| 70 | + do [[:block 0]] |
| 71 | + doseq [[:block 1]] |
| 72 | + dotimes [[:block 1]] |
| 73 | + doto [[:block 1]] |
| 74 | + extend [[:block 1]] |
| 75 | + extend-protocol [[:block 1] [:inner 1]] |
| 76 | + extend-type [[:block 1] [:inner 1]] |
| 77 | + fdef [[:inner 0]] |
| 78 | + finally [[:block 0]] |
| 79 | + fn [[:inner 0]] |
| 80 | + for [[:block 1]] |
| 81 | + future [[:block 0]] |
| 82 | + go [[:block 0]] |
| 83 | + go-loop [[:block 1]] |
| 84 | + if [[:block 1]] |
| 85 | + if-let [[:block 1]] |
| 86 | + if-not [[:block 1]] |
| 87 | + if-some [[:block 1]] |
| 88 | + let [[:block 1]] |
| 89 | + letfn [[:block 1] [:inner 2 0]] |
| 90 | + locking [[:block 1]] |
| 91 | + loop [[:block 1]] |
| 92 | + match [[:block 1]] |
| 93 | + ns [[:block 1]] |
| 94 | + proxy [[:block 2] [:inner 1]] |
| 95 | + reify [[:inner 0] [:inner 1]] |
| 96 | + struct-map [[:block 1]] |
| 97 | + testing [[:block 1]] |
| 98 | + thread [[:block 0]] |
| 99 | + try [[:block 0]] |
| 100 | + use-fixtures [[:inner 0]] |
| 101 | + when [[:block 1]] |
| 102 | + when-first [[:block 1]] |
| 103 | + when-let [[:block 1]] |
| 104 | + when-not [[:block 1]] |
| 105 | + when-some [[:block 1]] |
| 106 | + while [[:block 1]] |
| 107 | + with-local-vars [[:block 1]] |
| 108 | + with-open [[:block 1]] |
| 109 | + with-out-str [[:block 0]] |
| 110 | + with-precision [[:block 1]] |
| 111 | + with-redefs [[:block 1]]} |
| 112 | + |
| 113 | +;; Compojure |
| 114 | + |
| 115 | +#_ |
| 116 | +{ANY [[:inner 0]] |
| 117 | + DELETE [[:inner 0]] |
| 118 | + GET [[:inner 0]] |
| 119 | + HEAD [[:inner 0]] |
| 120 | + OPTIONS [[:inner 0]] |
| 121 | + PATCH [[:inner 0]] |
| 122 | + POST [[:inner 0]] |
| 123 | + PUT [[:inner 0]] |
| 124 | + context [[:inner 0]] |
| 125 | + defroutes [[:inner 0]] |
| 126 | + let-routes [[:block 1]] |
| 127 | + rfn [[:inner 0]]} |
| 128 | + |
| 129 | +;; fuzzy |
| 130 | +#_ |
| 131 | +{#"^def(?!ault)(?!late)(?!er)" [[:inner 0]] |
| 132 | + #"^with-" [[:inner 0]]} |
| 133 | + |
| 134 | + |
| 135 | +;; From Clojure LSP maintainer |
| 136 | + |
| 137 | +#_ |
| 138 | +{against-background [[:inner 0]] |
| 139 | + as-admin [[:block 1]] |
| 140 | + as-customer [[:block 1]] |
| 141 | + as-customer-with-lift [[:block 1]] |
| 142 | + as-delegate [[:block 2]] |
| 143 | + as-delegate-with-lift [[:block 2]] |
| 144 | + as-of [[:block 1]] |
| 145 | + assoc [[:block 1]] |
| 146 | + assoc-if [[:block 1]] |
| 147 | + assoc-in-if [[:block 1]] |
| 148 | + assoc-some [[:block 1]] |
| 149 | + assoc-in-some [[:block 1]] |
| 150 | + constraint-fn [[:block 2]] |
| 151 | + consume! [[:block 0]] |
| 152 | + data-fn [[:block 1]] |
| 153 | + defhandler [[:block 2]] |
| 154 | + defint [[:block 0]] |
| 155 | + defuf [[:block 1]] |
| 156 | + embeds [[:block 0]] |
| 157 | + expand-routes [[:inner 1]] |
| 158 | + fact [[:block 1]] |
| 159 | + facts [[:block 1]] |
| 160 | + flow [[:block 1]] |
| 161 | + flow-with-defaults [[:block 1]] |
| 162 | + flow-as-of [[:block 1]] |
| 163 | + flow-without-validation [[:block 1]] |
| 164 | + for-all [[:block 1]] |
| 165 | + future-fact [[:block 1]] |
| 166 | + future-facts [[:block 1]] |
| 167 | + idempotent-start [[:block 1]] |
| 168 | + idempotent-stop [[:block 1]] |
| 169 | + ignore-conflict [[:inner 0]] |
| 170 | + let-entities [[:block 2]] |
| 171 | + let-flow [[:block 1]] |
| 172 | + log-messages [[:block 0]] |
| 173 | + logged-call [[:block 1]] |
| 174 | + non-test-action [[:inner 0]] |
| 175 | + profile [[:block 2]] |
| 176 | + profiled [[:block 1]] |
| 177 | + provided [[:inner 0]] |
| 178 | + quick-check [[:block 1]] |
| 179 | + rethrow [[:block 1]] |
| 180 | + run-recipe [[:inner 0]] |
| 181 | + some-with-open [[:block 1]] |
| 182 | + system-map [[:block 0]] |
| 183 | + tabular [[:inner 0]] |
| 184 | + try-type [[:block 0]] |
| 185 | + with-cid [[:block 1]] |
| 186 | + with-fn-validation [[:block 0]] |
| 187 | + with-responses [[:block 0]] |
| 188 | + with-scopes [[:block 1]]} |
0 commit comments