|
1 | 1 | ; CREDITS @stumash (stuart.mashaal@gmail.com) |
2 | | - |
3 | | -(field_expression field: (identifier) @property) |
4 | | -(field_expression value: (identifier) @type |
5 | | - (#match? @type "^[A-Z]")) |
6 | | - |
7 | | -(type_identifier) @type |
8 | | - |
9 | 2 | (class_definition |
10 | 3 | name: (identifier) @type) |
11 | 4 |
|
|
24 | 17 | (simple_enum_case |
25 | 18 | name: (identifier) @type) |
26 | 19 |
|
27 | | -;; variables |
28 | | - |
| 20 | +; variables |
29 | 21 | (class_parameter |
30 | | - name: (identifier) @parameter) |
| 22 | + name: (identifier) @variable.parameter) |
31 | 23 |
|
32 | | -(self_type (identifier) @parameter) |
| 24 | +(self_type |
| 25 | + (identifier) @variable.parameter) |
33 | 26 |
|
34 | | -(interpolation (identifier) @none) |
35 | | -(interpolation (block) @none) |
| 27 | +(interpolation |
| 28 | + (identifier) @none) |
36 | 29 |
|
37 | | -;; types |
| 30 | +(interpolation |
| 31 | + (block) @none) |
38 | 32 |
|
| 33 | +; types |
39 | 34 | (type_definition |
40 | 35 | name: (type_identifier) @type.definition) |
41 | 36 |
|
42 | | -;; val/var definitions/declarations |
| 37 | +(type_identifier) @type |
43 | 38 |
|
| 39 | +; val/var definitions/declarations |
44 | 40 | (val_definition |
45 | 41 | pattern: (identifier) @variable) |
46 | 42 |
|
|
53 | 49 | (var_declaration |
54 | 50 | name: (identifier) @variable) |
55 | 51 |
|
56 | | -; imports/exports |
| 52 | +; method definition |
| 53 | +(function_declaration |
| 54 | + name: (identifier) @function.method) |
| 55 | + |
| 56 | +(function_definition |
| 57 | + name: (identifier) @function.method) |
57 | 58 |
|
| 59 | +; imports/exports |
58 | 60 | (import_declaration |
59 | | - path: (identifier) @namespace) |
60 | | -((stable_identifier (identifier) @namespace)) |
| 61 | + path: (identifier) @module) |
| 62 | + |
| 63 | +(stable_identifier |
| 64 | + (identifier) @module) |
61 | 65 |
|
62 | 66 | ((import_declaration |
63 | | - path: (identifier) @type) (#match? @type "^[A-Z]")) |
64 | | -((stable_identifier (identifier) @type) (#match? @type "^[A-Z]")) |
| 67 | + path: (identifier) @type) |
| 68 | + (#lua-match? @type "^[A-Z]")) |
| 69 | + |
| 70 | +((stable_identifier |
| 71 | + (identifier) @type) |
| 72 | + (#lua-match? @type "^[A-Z]")) |
65 | 73 |
|
66 | 74 | (export_declaration |
67 | | - path: (identifier) @namespace) |
68 | | -((stable_identifier (identifier) @namespace)) |
| 75 | + path: (identifier) @module) |
| 76 | + |
| 77 | +(stable_identifier |
| 78 | + (identifier) @module) |
69 | 79 |
|
70 | 80 | ((export_declaration |
71 | | - path: (identifier) @type) (#match? @type "^[A-Z]")) |
72 | | -((stable_identifier (identifier) @type) (#match? @type "^[A-Z]")) |
| 81 | + path: (identifier) @type) |
| 82 | + (#lua-match? @type "^[A-Z]")) |
73 | 83 |
|
74 | | -((namespace_selectors (identifier) @type) (#match? @type "^[A-Z]")) |
| 84 | +((stable_identifier |
| 85 | + (identifier) @type) |
| 86 | + (#lua-match? @type "^[A-Z]")) |
75 | 87 |
|
76 | | -; method invocation |
| 88 | +((namespace_selectors |
| 89 | + (identifier) @type) |
| 90 | + (#lua-match? @type "^[A-Z]")) |
77 | 91 |
|
| 92 | +; method invocation |
78 | 93 | (call_expression |
79 | 94 | function: (identifier) @function.call) |
80 | 95 |
|
|
83 | 98 |
|
84 | 99 | (call_expression |
85 | 100 | function: (field_expression |
86 | | - field: (identifier) @method.call)) |
| 101 | + field: (identifier) @function.method.call)) |
87 | 102 |
|
88 | 103 | ((call_expression |
89 | | - function: (identifier) @constructor) |
90 | | - (#match? @constructor "^[A-Z]")) |
| 104 | + function: (identifier) @constructor) |
| 105 | + (#lua-match? @constructor "^[A-Z]")) |
91 | 106 |
|
92 | 107 | (generic_function |
93 | 108 | function: (identifier) @function.call) |
|
96 | 111 | interpolator: (identifier) @function.call) |
97 | 112 |
|
98 | 113 | ; function definitions |
99 | | - |
100 | 114 | (function_definition |
101 | 115 | name: (identifier) @function) |
102 | 116 |
|
103 | 117 | (parameter |
104 | | - name: (identifier) @parameter) |
| 118 | + name: (identifier) @variable.parameter) |
105 | 119 |
|
106 | 120 | (binding |
107 | | - name: (identifier) @parameter) |
| 121 | + name: (identifier) @variable.parameter) |
108 | 122 |
|
109 | | -; method definition |
| 123 | +(lambda_expression |
| 124 | + parameters: (identifier) @variable.parameter) |
110 | 125 |
|
111 | | -(function_declaration |
112 | | - name: (identifier) @method) |
| 126 | +; expressions |
| 127 | +(field_expression |
| 128 | + field: (identifier) @variable.member) |
113 | 129 |
|
114 | | -(function_definition |
115 | | - name: (identifier) @method) |
| 130 | +(field_expression |
| 131 | + value: (identifier) @type |
| 132 | + (#lua-match? @type "^[A-Z]")) |
116 | 133 |
|
117 | | -; expressions |
| 134 | +(infix_expression |
| 135 | + operator: (identifier) @operator) |
118 | 136 |
|
119 | | -(infix_expression operator: (identifier) @operator) |
120 | | -(infix_expression operator: (operator_identifier) @operator) |
121 | | -(infix_type operator: (operator_identifier) @operator) |
122 | | -(infix_type operator: (operator_identifier) @operator) |
| 137 | +(infix_expression |
| 138 | + operator: (operator_identifier) @operator) |
123 | 139 |
|
124 | | -; literals |
| 140 | +(infix_type |
| 141 | + operator: (operator_identifier) @operator) |
| 142 | + |
| 143 | +(infix_type |
| 144 | + operator: (operator_identifier) @operator) |
125 | 145 |
|
| 146 | +; literals |
126 | 147 | (boolean_literal) @boolean |
| 148 | + |
127 | 149 | (integer_literal) @number |
128 | | -(floating_point_literal) @float |
| 150 | + |
| 151 | +(floating_point_literal) @number.float |
129 | 152 |
|
130 | 153 | [ |
131 | | - (symbol_literal) |
132 | 154 | (string) |
133 | | - (character_literal) |
134 | 155 | (interpolated_string_expression) |
135 | 156 | ] @string |
136 | 157 |
|
137 | | -(interpolation "$" @punctuation.special) |
| 158 | +(character_literal) @character |
| 159 | + |
| 160 | +(symbol_literal) @string.special.symbol |
| 161 | + |
| 162 | +(interpolation |
| 163 | + "$" @punctuation.special) |
138 | 164 |
|
139 | | -;; keywords |
| 165 | +; keywords |
| 166 | +(opaque_modifier) @keyword.modifier |
140 | 167 |
|
141 | | -(opaque_modifier) @type.qualifier |
142 | 168 | (infix_modifier) @keyword |
143 | | -(transparent_modifier) @type.qualifier |
144 | | -(open_modifier) @type.qualifier |
| 169 | + |
| 170 | +(transparent_modifier) @keyword.modifier |
| 171 | + |
| 172 | +(open_modifier) @keyword.modifier |
145 | 173 |
|
146 | 174 | [ |
147 | 175 | "case" |
148 | | - "class" |
149 | | - "enum" |
150 | 176 | "extends" |
151 | 177 | "derives" |
152 | 178 | "finally" |
153 | | -;; `forSome` existential types not implemented yet |
154 | | -;; `macro` not implemented yet |
| 179 | + ; `forSome` existential types not implemented yet |
| 180 | + ; `macro` not implemented yet |
155 | 181 | "object" |
156 | 182 | "override" |
157 | | - "package" |
158 | | - "trait" |
159 | | - "type" |
160 | 183 | "val" |
161 | 184 | "var" |
162 | 185 | "with" |
|
168 | 191 | "with" |
169 | 192 | ] @keyword |
170 | 193 |
|
| 194 | +[ |
| 195 | + "enum" |
| 196 | + "class" |
| 197 | + "trait" |
| 198 | + "type" |
| 199 | +] @keyword.type |
| 200 | + |
171 | 201 | [ |
172 | 202 | "abstract" |
173 | 203 | "final" |
174 | 204 | "lazy" |
175 | 205 | "sealed" |
176 | 206 | "private" |
177 | 207 | "protected" |
178 | | -] @type.qualifier |
| 208 | +] @keyword.modifier |
179 | 209 |
|
180 | | -(inline_modifier) @storageclass |
| 210 | +(inline_modifier) @keyword.modifier |
181 | 211 |
|
182 | 212 | (null_literal) @constant.builtin |
183 | 213 |
|
184 | | -(wildcard) @parameter |
| 214 | +(wildcard) @variable.parameter |
185 | 215 |
|
186 | | -(annotation) @attribute |
| 216 | +(namespace_wildcard |
| 217 | + [ |
| 218 | + "*" |
| 219 | + "_" |
| 220 | + ] @character.special) |
187 | 221 |
|
188 | | -;; special keywords |
| 222 | +(annotation) @attribute |
189 | 223 |
|
| 224 | +; special keywords |
190 | 225 | "new" @keyword.operator |
191 | 226 |
|
192 | 227 | [ |
193 | 228 | "else" |
194 | 229 | "if" |
195 | 230 | "match" |
196 | 231 | "then" |
197 | | -] @conditional |
| 232 | +] @keyword.conditional |
198 | 233 |
|
199 | 234 | [ |
200 | | - "(" |
201 | | - ")" |
202 | | - "[" |
203 | | - "]" |
204 | | - "{" |
205 | | - "}" |
206 | | -] @punctuation.bracket |
| 235 | + "(" |
| 236 | + ")" |
| 237 | + "[" |
| 238 | + "]" |
| 239 | + "{" |
| 240 | + "}" |
| 241 | +] @punctuation.bracket |
207 | 242 |
|
208 | 243 | [ |
209 | | - "." |
210 | | - "," |
| 244 | + "." |
| 245 | + "," |
| 246 | + ":" |
211 | 247 | ] @punctuation.delimiter |
212 | 248 |
|
213 | 249 | [ |
214 | 250 | "do" |
215 | 251 | "for" |
216 | 252 | "while" |
217 | 253 | "yield" |
218 | | -] @repeat |
| 254 | +] @keyword.repeat |
219 | 255 |
|
220 | 256 | "def" @keyword.function |
221 | 257 |
|
222 | 258 | [ |
223 | | - "=>" |
224 | | - "<-" |
225 | | - "@" |
| 259 | + "=>" |
| 260 | + "?=>" |
| 261 | + "=" |
| 262 | + "!" |
| 263 | + "<-" |
| 264 | + "@" |
226 | 265 | ] @operator |
227 | 266 |
|
228 | | -["import" "export"] @include |
| 267 | +[ |
| 268 | + "import" |
| 269 | + "export" |
| 270 | + "package" |
| 271 | +] @keyword.import |
229 | 272 |
|
230 | 273 | [ |
231 | 274 | "try" |
232 | 275 | "catch" |
233 | 276 | "throw" |
234 | | -] @exception |
| 277 | +] @keyword.exception |
235 | 278 |
|
236 | 279 | "return" @keyword.return |
237 | 280 |
|
238 | | -(comment) @spell @comment |
239 | | -(block_comment) @spell @comment |
| 281 | +[ |
| 282 | + (comment) |
| 283 | + (block_comment) |
| 284 | +] @comment @spell |
| 285 | + |
| 286 | +((block_comment) @comment.documentation |
| 287 | + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) |
240 | 288 |
|
241 | | -;; `case` is a conditional keyword in case_block |
| 289 | +; `case` is a conditional keyword in case_block |
| 290 | +(case_block |
| 291 | + (case_clause |
| 292 | + "case" @keyword.conditional)) |
242 | 293 |
|
243 | 294 | (case_block |
244 | | - (case_clause ("case") @conditional)) |
245 | | -(indented_cases |
246 | | - (case_clause ("case") @conditional)) |
| 295 | + (case_clause |
| 296 | + "=>" @punctuation.delimiter)) |
247 | 297 |
|
248 | 298 | (operator_identifier) @operator |
249 | 299 |
|
250 | | -((identifier) @type (#match? @type "^[A-Z]")) |
| 300 | +((identifier) @type |
| 301 | + (#lua-match? @type "^[A-Z]")) |
| 302 | + |
251 | 303 | ((identifier) @variable.builtin |
252 | | - (#match? @variable.builtin "^this$")) |
| 304 | + (#lua-match? @variable.builtin "^this$")) |
| 305 | + |
| 306 | +((identifier) @function.builtin |
| 307 | + (#lua-match? @function.builtin "^super$")) |
253 | 308 |
|
254 | | -( |
255 | | - (identifier) @function.builtin |
256 | | - (#match? @function.builtin "^super$") |
257 | | -) |
| 309 | +; Scala CLI using directives |
| 310 | +(using_directive_key) @variable.parameter |
258 | 311 |
|
259 | | -;; Scala CLI using directives |
260 | | -(using_directive_key) @parameter |
261 | 312 | (using_directive_value) @string |
0 commit comments