|
6 | 6 | ;; For the most part this means that some things have to be assigned multiple
|
7 | 7 | ;; groups.
|
8 | 8 | ;; By doing this we can add a basic capture and then later refine it with more
|
9 |
| -;; specialied captures. |
| 9 | +;; specialized captures. |
10 | 10 | ;; This can mean that sometimes things are highlighted weirdly because they
|
11 | 11 | ;; have multiple highlight groups applied to them.
|
12 | 12 |
|
13 | 13 |
|
14 | 14 | ;; >> Literals
|
15 | 15 |
|
| 16 | +( |
| 17 | + (dis_expr) @comment |
| 18 | + (#set! "priority" 105) ; Higher priority to mark the whole sexpr as a comment |
| 19 | +) |
16 | 20 | (kwd_lit) @symbol
|
17 | 21 | (str_lit) @string
|
18 | 22 | (num_lit) @number
|
19 | 23 | (char_lit) @character
|
20 | 24 | (bool_lit) @boolean
|
21 | 25 | (nil_lit) @constant.builtin
|
22 |
| -(comment) @comment |
| 26 | +(comment) @comment @spell |
23 | 27 | (regex_lit) @string.regex
|
24 | 28 |
|
25 | 29 | ["'" "`"] @string.escape
|
|
51 | 55 |
|
52 | 56 | ; Used in destructure pattern
|
53 | 57 | ((sym_lit) @parameter
|
54 |
| - (#match? @parameter "^[&]")) |
| 58 | + (#lua-match? @parameter "^[&]")) |
55 | 59 |
|
56 | 60 | ; Inline function variables
|
57 | 61 | ((sym_lit) @variable.builtin
|
58 |
| - (#match? @variable.builtin "^[%]")) |
| 62 | + (#lua-match? @variable.builtin "^%%")) |
59 | 63 |
|
60 | 64 | ; Constructor
|
61 |
| -;;((sym_lit) @constructor |
62 |
| -;; (#match? @constructor "^-\\>[^\\>].*")) |
| 65 | +((sym_lit) @constructor |
| 66 | + (#lua-match? @constructor "^-%>[^>].*")) |
63 | 67 |
|
64 |
| -; Dynamic variables |
| 68 | +; Builtin dynamic variables |
65 | 69 | ((sym_lit) @variable.builtin
|
66 |
| - (#match? @variable.builtin "^[*].+[*]$")) |
| 70 | + (#any-of? @variable.builtin |
| 71 | + "*agent*" "*allow-unresolved-vars*" "*assert*" |
| 72 | + "*clojure-version*" "*command-line-args*" |
| 73 | + "*compile-files*" "*compile-path*" "*compiler-options*" |
| 74 | + "*data-readers*" "*default-data-reader-fn*" |
| 75 | + "*err*" "*file*" "*flush-on-newline*" "*fn-loader*" |
| 76 | + "*in*" "*math-context*" "*ns*" "*out*" |
| 77 | + "*print-dup*" "*print-length*" "*print-level*" |
| 78 | + "*print-meta*" "*print-namespace-maps*" "*print-readably*" |
| 79 | + "*read-eval*" "*reader-resolver*" |
| 80 | + "*source-path*" "*suppress-read*" |
| 81 | + "*unchecked-math*" "*use-context-classloader*" |
| 82 | + "*verbose-defrecords*" "*warn-on-reflection*")) |
| 83 | + |
| 84 | +; Builtin repl variables |
| 85 | +((sym_lit) @variable.builtin |
| 86 | + (#any-of? @variable.builtin |
| 87 | + "*1" "*2" "*3" "*e")) |
67 | 88 |
|
68 | 89 | ; Gensym
|
69 | 90 | ;; Might not be needed
|
70 | 91 | ((sym_lit) @variable
|
71 |
| - (#match? @variable "^.*#$")) |
| 92 | + (#lua-match? @variable "^.*#$")) |
72 | 93 |
|
73 | 94 | ; Types
|
74 | 95 | ;; TODO: improve?
|
75 | 96 | ((sym_lit) @type
|
76 |
| - (#match? @type "^[A-Z][^/]*$")) |
| 97 | + (#lua-match? @type "^[%u][^/]*$")) |
77 | 98 | ;; Symbols with `.` but not `/`
|
78 | 99 | ((sym_lit) @type
|
79 |
| - (#match? @type "^[^/]+[.][^/]*$")) |
| 100 | + (#lua-match? @type "^[^/]+[.][^/]*$")) |
80 | 101 |
|
81 | 102 | ; Interop
|
| 103 | +; (.instanceMember instance args*) |
| 104 | +; (.instanceMember Classname args*) |
82 | 105 | ((sym_lit) @method
|
83 |
| - (#match? @method "^\\.[^-]")) |
| 106 | + (#lua-match? @method "^%.[^-]")) |
| 107 | +; (.-instanceField instance) |
84 | 108 | ((sym_lit) @field
|
85 |
| - (#match? @field "^\\.-")) |
| 109 | + (#lua-match? @field "^%.%-.*")) |
| 110 | +; Classname/staticField |
86 | 111 | ((sym_lit) @field
|
87 |
| - (#match? @field "^[A-Z].*/.+")) |
| 112 | + (#lua-match? @field "^[%u].*/.+")) |
| 113 | +; (Classname/staticMethod args*) |
88 | 114 | (list_lit
|
89 | 115 | .
|
90 | 116 | (sym_lit) @method
|
91 |
| - (#match? @method "^[A-Z].*/.+")) |
| 117 | + (#lua-match? @method "^[%u].*/.+")) |
92 | 118 | ;; TODO: Special casing for the `.` macro
|
93 | 119 |
|
94 | 120 | ; Operators
|
|
103 | 129 | ; Definition functions
|
104 | 130 | ((sym_lit) @keyword
|
105 | 131 | (#any-of? @keyword
|
106 |
| - "def" "defonce" "defrecord" "defmacro" "definline" |
| 132 | + "def" "defonce" "defrecord" "defmacro" "definline" "definterface" |
107 | 133 | "defmulti" "defmethod" "defstruct" "defprotocol"
|
108 | 134 | "deftype"))
|
109 | 135 | ((sym_lit) @keyword
|
110 | 136 | (#eq? @keyword "declare"))
|
| 137 | +((sym_name) @keyword.coroutine |
| 138 | + (#any-of? @keyword.coroutine |
| 139 | + "alts!" "alts!!" "await" "await-for" "await1" "chan" "close!" "future" "go" "sync" "thread" "timeout" "<!" "<!!" ">!" ">!!")) |
111 | 140 | ((sym_lit) @keyword.function
|
112 |
| - (#match? @keyword.function "^(defn|defn-|fn|fn[*])$")) |
| 141 | + (#any-of? @keyword.function "defn" "defn-" "fn" "fn*")) |
113 | 142 |
|
114 | 143 | ; Comment
|
115 | 144 | ((sym_lit) @comment
|
|
120 | 149 | (#any-of? @conditional
|
121 | 150 | "case" "cond" "cond->" "cond->>" "condp"))
|
122 | 151 | ((sym_lit) @conditional
|
123 |
| - (#match? @conditional "^if(\\-.*)?$")) |
| 152 | + (#any-of? @conditional |
| 153 | + "if" "if-let" "if-not" "if-some")) |
124 | 154 | ((sym_lit) @conditional
|
125 |
| - (#match? @conditional "^when(\\-.*)?$")) |
| 155 | + (#any-of? @conditional |
| 156 | + "when" "when-first" "when-let" "when-not" "when-some")) |
126 | 157 |
|
127 | 158 | ; Repeats
|
128 | 159 | ((sym_lit) @repeat
|
|
132 | 163 | ; Exception
|
133 | 164 | ((sym_lit) @exception
|
134 | 165 | (#any-of? @exception
|
135 |
| - "throw" "try" "catch" "finally" "ex-info")) |
| 166 | + "throw" "try" "catch" "finally")) |
136 | 167 |
|
137 | 168 | ; Includes
|
138 | 169 | ((sym_lit) @include
|
|
144 | 175 | (#any-of? @function.macro
|
145 | 176 | "." ".." "->" "->>" "amap" "areduce" "as->" "assert"
|
146 | 177 | "binding" "bound-fn" "delay" "do" "dosync"
|
147 |
| - "doto" "extend-protocol" "extend-type" "future" |
| 178 | + "doto" "extend-protocol" "extend-type" |
148 | 179 | "gen-class" "gen-interface" "io!" "lazy-cat"
|
149 | 180 | "lazy-seq" "let" "letfn" "locking" "memfn" "monitor-enter"
|
150 | 181 | "monitor-exit" "proxy" "proxy-super" "pvalues"
|
151 |
| - "refer-clojure" "reify" "set!" "some->" "some->>" "sync" |
| 182 | + "refer-clojure" "reify" "set!" "some->" "some->>" |
152 | 183 | "time" "unquote" "unquote-splicing" "var" "vswap!"
|
153 |
| - "ex-cause" "ex-data" "ex-message")) |
154 |
| -((sym_lit) @function.macro |
155 |
| - (#match? @function.macro "^with\\-.*$")) |
| 184 | + "with-bindings" "with-in-str" "with-loading-context" "with-local-vars" |
| 185 | + "with-open" "with-out-str" "with-precision" "with-redefs")) |
156 | 186 |
|
157 | 187 | ; All builtin functions
|
158 | 188 | ; (->> (ns-publics *ns*)
|
159 | 189 | ; (keep (fn [[s v]] (when-not (:macro (meta v)) s)))
|
160 | 190 | ; sort
|
161 |
| -; cp/print)) |
| 191 | +; clojure.pprint/pprint)) |
162 | 192 | ;; ...and then lots of manual filtering...
|
163 | 193 | ((sym_lit) @function.builtin
|
164 | 194 | (#any-of? @function.builtin
|
|
171 | 201 | "any?" "apply" "array-map" "aset" "aset-boolean" "aset-byte"
|
172 | 202 | "aset-char" "aset-double" "aset-float" "aset-int"
|
173 | 203 | "aset-long" "aset-short" "assoc" "assoc!" "assoc-in"
|
174 |
| - "associative?" "atom" "await" "await-for" "await1" |
175 |
| - "bases" "bean" "bigdec" "bigint" "biginteger" "bit-and" |
176 |
| - "bit-and-not" "bit-clear" "bit-flip" "bit-not" "bit-or" |
| 204 | + "associative?" "atom" "bases" "bean" "bigdec" "bigint" "biginteger" |
| 205 | + "bit-and" "bit-and-not" "bit-clear" "bit-flip" "bit-not" "bit-or" |
177 | 206 | "bit-set" "bit-shift-left" "bit-shift-right" "bit-test"
|
178 | 207 | "bit-xor" "boolean" "boolean-array" "boolean?"
|
179 | 208 | "booleans" "bound-fn*" "bound?" "bounded-count"
|
|
271 | 300 | "val" "vals" "var-get" "var-set" "var?" "vary-meta" "vec"
|
272 | 301 | "vector" "vector-of" "vector?" "volatile!" "volatile?"
|
273 | 302 | "vreset!" "with-bindings*" "with-meta" "with-redefs-fn" "xml-seq"
|
274 |
| - "zero?" "zipmap")) |
| 303 | + "zero?" "zipmap" |
| 304 | + ;; earlier |
| 305 | + "drop" "drop-last" "drop-while" |
| 306 | + "double?" "doubles" |
| 307 | + "ex-data" "ex-info" |
| 308 | + ;; 1.10 |
| 309 | + "ex-cause" "ex-message" |
| 310 | + ;; 1.11 |
| 311 | + "NaN?" "abs" "infinite?" "iteration" "random-uuid" |
| 312 | + "parse-boolean" "parse-double" "parse-long" "parse-uuid" |
| 313 | + "seq-to-map-for-destructuring" "update-keys" "update-vals" |
| 314 | + ;; 1.12 |
| 315 | + "partitionv" "partitionv-all" "splitv-at")) |
275 | 316 |
|
276 | 317 |
|
277 | 318 |
|
|
0 commit comments