|
12 | 12 | "use strict";
|
13 | 13 |
|
14 | 14 | CodeMirror.defineMode("clojure", function (options) {
|
15 |
| - var commonAtoms = ["false", "nil", "true"]; |
16 |
| - var commonSpecialForms = [".", "catch", "def", "do", "if", "monitor-enter", |
| 15 | + var atoms = ["false", "nil", "true"]; |
| 16 | + var specialForms = [".", "catch", "def", "do", "if", "monitor-enter", |
17 | 17 | "monitor-exit", "new", "quote", "recur", "set!", "throw", "try", "var"];
|
18 |
| - var commonCoreSymbols = ["*", "*'", "*1", "*2", "*3", "*agent*", |
| 18 | + var coreSymbols = ["*", "*'", "*1", "*2", "*3", "*agent*", |
19 | 19 | "*allow-unresolved-vars*", "*assert*", "*clojure-version*",
|
20 | 20 | "*command-line-args*", "*compile-files*", "*compile-path*",
|
21 | 21 | "*compiler-options*", "*data-readers*", "*default-data-reader-fn*", "*e",
|
@@ -137,23 +137,22 @@ CodeMirror.defineMode("clojure", function (options) {
|
137 | 137 | "with-local-vars", "with-meta", "with-open", "with-out-str",
|
138 | 138 | "with-precision", "with-redefs", "with-redefs-fn", "xml-seq", "zero?",
|
139 | 139 | "zipmap"];
|
140 |
| - var commonIndentSymbols = [ |
| 140 | + var formsThatHaveBodyParameter = [ |
141 | 141 | "assoc", "binding", "bound-fn", "case", "catch", "comment", "cond",
|
142 |
| - "condp", "def", "defmethod", "defn", "defprotocol", "defrecord", |
143 |
| - "defstruct", "deftype", "do", "doseq", "dotimes", "doto", "extend", |
144 |
| - "extend-protocol", "extend-type", "fn", "for", "future", "if", "if-let", |
145 |
| - "if-not", "let", "letfn", "locking", "loop", "ns", "proxy", "reify", |
146 |
| - "struct-map", "try", "when", "when-first", "when-let", "when-not", |
147 |
| - "when-some", "while", "with-open", "with-precision"]; |
| 142 | + "condp", "def", "defmethod", "defn", "defmacro", "defprotocol", |
| 143 | + "defrecord", "defstruct", "deftype", "do", "doseq", "dotimes", "doto", |
| 144 | + "extend", "extend-protocol", "extend-type", "fn", "for", "future", "if", |
| 145 | + "if-let", "if-not", "let", "letfn", "locking", "loop", "ns", "proxy", |
| 146 | + "reify", "struct-map", "try", "when", "when-first", "when-let", |
| 147 | + "when-not", "when-some", "while", "with-open", "with-precision"]; |
148 | 148 |
|
149 | 149 | CodeMirror.registerHelper("hintWords", "clojure",
|
150 |
| - commonAtoms.concat(commonSpecialForms, commonCoreSymbols)); |
| 150 | + [].concat(atoms, specialForms, coreSymbols)); |
151 | 151 |
|
152 |
| - var atom = createLookupMap(commonAtoms); |
153 |
| - var specialForm = createLookupMap(commonSpecialForms); |
154 |
| - var coreSymbol = createLookupMap(commonCoreSymbols); |
155 |
| - var indentSymbol = createLookupMap(commonIndentSymbols); |
156 |
| - var assumeBody = /^(?:def|with)[^\/]+$|\/(?:def|with)/; |
| 152 | + var atom = createLookupMap(atoms); |
| 153 | + var specialForm = createLookupMap(specialForms); |
| 154 | + var coreSymbol = createLookupMap(coreSymbols); |
| 155 | + var hasBodyParameter = createLookupMap(formsThatHaveBodyParameter); |
157 | 156 | var numberLiteral = /^[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?/;
|
158 | 157 | var symbol = /[!#'*+\-.\/:<>?_\w\xa1-\uffff]/;
|
159 | 158 |
|
@@ -253,8 +252,7 @@ CodeMirror.defineMode("clojure", function (options) {
|
253 | 252 |
|
254 | 253 | if (type !== "space") {
|
255 | 254 | if (state.lastToken === "(" && state.ctx.indentTo === null) {
|
256 |
| - if (type === "symbol" && |
257 |
| - (is(current, indentSymbol) || is(current, assumeBody))) |
| 255 | + if (type === "symbol" && is(current, hasBodyParameter)) |
258 | 256 | state.ctx.indentTo = state.ctx.start + options.indentUnit;
|
259 | 257 | else state.ctx.indentTo = "next";
|
260 | 258 | } else if (state.ctx.indentTo === "next") {
|
|
0 commit comments