Elffuss BraidHub

kikocis/continue public

2d2c10bf01a5 · 13.8 KiBRawPermalink
1{
2 "name": "Rust",
3 "scopeName": "source.rust",
4 "fileTypes": [
5 "rs"
6 ],
7 "repository": {
8 "block_doc_comment": {
9 "comment": "Block documentation comment",
10 "name": "comment.block.documentation.rust",
11 "begin": "/\\*[\\*!](?![\\*/])",
12 "end": "\\*/",
13 "patterns": [
14 {
15 "include": "#block_doc_comment"
16 },
17 {
18 "include": "#block_comment"
19 }
20 ]
21 },
22 "block_comment": {
23 "comment": "Block comment",
24 "name": "comment.block.rust",
25 "begin": "/\\*",
26 "end": "\\*/",
27 "patterns": [
28 {
29 "include": "#block_doc_comment"
30 },
31 {
32 "include": "#block_comment"
33 }
34 ]
35 },
36 "line_doc_comment": {
37 "comment": "Single-line documentation comment",
38 "name": "comment.line.documentation.rust",
39 "begin": "//[!/](?=[^/])",
40 "end": "$"
41 },
42 "line_comment": {
43 "comment": "Single-line comment",
44 "name": "comment.line.double-slash.rust",
45 "begin": "//",
46 "end": "$"
47 },
48 "escaped_character": {
49 "name": "constant.character.escape.rust",
50 "match": "\\\\(x\\h{2}|[0-2][0-7]{,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)"
51 },
52 "string_literal": {
53 "comment": "Double-quote string literal",
54 "name": "string.quoted.double.rust",
55 "begin": "b?\"",
56 "end": "\"",
57 "patterns": [
58 {
59 "include": "#escaped_character"
60 }
61 ]
62 },
63 "raw_string_literal": {
64 "comment": "Raw double-quote string literal",
65 "name": "string.quoted.double.raw.rust",
66 "begin": "b?r(#*)\"",
67 "end": "\"\\1"
68 },
69 "sigils": {
70 "comment": "Sigil",
71 "name": "keyword.operator.sigil.rust",
72 "match": "[&*](?=[a-zA-Z0-9_\\(\\[\\|\\\"]+)"
73 },
74 "self": {
75 "comment": "Self variable",
76 "name": "variable.language.rust",
77 "match": "\\bself\\b"
78 },
79 "mut": {
80 "comment": "Mutable storage modifier",
81 "name": "storage.modifier.mut.rust",
82 "match": "\\bmut\\b"
83 },
84 "box": {
85 "comment": "Box storage modifier",
86 "name": "storage.modifier.box.rust",
87 "match": "\\bbox\\b"
88 },
89 "const": {
90 "comment": "Const storage modifier",
91 "name": "storage.modifier.const.rust",
92 "match": "\\bconst\\b"
93 },
94 "pub": {
95 "comment": "Visibility modifier",
96 "name": "storage.modifier.visibility.rust",
97 "match": "\\bpub\\b"
98 },
99 "lifetime": {
100 "comment": "Named lifetime",
101 "name": "storage.modifier.lifetime.rust",
102 "match": "'([a-zA-Z_][a-zA-Z0-9_]*)\\b",
103 "captures": {
104 "1": {
105 "name": "entity.name.lifetime.rust"
106 }
107 }
108 },
109 "ref_lifetime": {
110 "comment": "Reference with named lifetime",
111 "match": "&('([a-zA-Z_][a-zA-Z0-9_]*))\\b",
112 "captures": {
113 "1": {
114 "name": "storage.modifier.lifetime.rust"
115 },
116 "2": {
117 "name": "entity.name.lifetime.rust"
118 }
119 }
120 },
121 "core_types": {
122 "comment": "Built-in/core type",
123 "name": "storage.type.core.rust",
124 "match": "\\b(bool|char|usize|isize|u8|u16|u32|u64|i8|i16|i32|i64|f32|f64|str|Self|Option|Result)\\b"
125 },
126 "core_vars": {
127 "comment": "Core type variant",
128 "name": "support.constant.core.rust",
129 "match": "\\b(Some|None|Ok|Err)\\b"
130 },
131 "core_marker": {
132 "comment": "Core trait (marker)",
133 "name": "support.type.marker.rust",
134 "match": "\\b(Copy|Send|Sized|Sync)\\b"
135 },
136 "core_traits": {
137 "comment": "Core trait",
138 "name": "support.type.core.rust",
139 "match": "\\b(Drop|Fn|FnMut|FnOnce|Clone|PartialEq|PartialOrd|Eq|Ord|AsRef|AsMut|Into|From|Default|Iterator|Extend|IntoIterator|DoubleEndedIterator|ExactSizeIterator)\\b"
140 },
141 "where": {
142 "comment": "Where clause",
143 "name": "keyword.other.rust",
144 "match": "\\bwhere\\b"
145 },
146 "std_types": {
147 "comment": "Standard library type",
148 "name": "storage.class.std.rust",
149 "match": "\\b(Box|String|Vec|Path|PathBuf)\\b"
150 },
151 "std_traits": {
152 "comment": "Standard library trait",
153 "name": "support.type.std.rust",
154 "match": "\\b(ToOwned|ToString)\\b"
155 },
156 "type_params": {
157 "comment": "Type parameters",
158 "name": "meta.type_params.rust",
159 "begin": "<(?![=<])",
160 "end": ">",
161 "patterns": [
162 {
163 "include": "#block_comment"
164 },
165 {
166 "include": "#line_comment"
167 },
168 {
169 "include": "#sigils"
170 },
171 {
172 "include": "#mut"
173 },
174 {
175 "include": "#lifetime"
176 },
177 {
178 "include": "#core_types"
179 },
180 {
181 "include": "#core_marker"
182 },
183 {
184 "include": "#core_traits"
185 },
186 {
187 "include": "#std_types"
188 },
189 {
190 "include": "#std_traits"
191 },
192 {
193 "include": "#type_params"
194 }
195 ]
196 }
197 },
198 "patterns": [
199 {
200 "include": "#block_doc_comment"
201 },
202 {
203 "include": "#block_comment"
204 },
205 {
206 "include": "#line_doc_comment"
207 },
208 {
209 "include": "#line_comment"
210 },
211 {
212 "comment": "Attribute",
213 "name": "meta.attribute.rust",
214 "begin": "#\\!?\\[",
215 "end": "\\]",
216 "patterns": [
217 {
218 "include": "#string_literal"
219 }
220 ]
221 },
222 {
223 "comment": "Single-quote string literal (character)",
224 "name": "string.quoted.single.rust",
225 "match": "b?'([^'\\\\]|\\\\(x\\h{2}|[0-2][0-7]{,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.))'"
226 },
227 {
228 "include": "#string_literal"
229 },
230 {
231 "include": "#raw_string_literal"
232 },
233 {
234 "comment": "Floating point literal (fraction)",
235 "name": "constant.numeric.float.rust",
236 "match": "\\b[0-9][0-9_]*\\.[0-9][0-9_]*([eE][+-]?[0-9_]+)?(f32|f64)?\\b"
237 },
238 {
239 "comment": "Floating point literal (exponent)",
240 "name": "constant.numeric.float.rust",
241 "match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?[eE][+-]?[0-9_]+(f32|f64)?\\b"
242 },
243 {
244 "comment": "Floating point literal (typed)",
245 "name": "constant.numeric.float.rust",
246 "match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?([eE][+-]?[0-9_]+)?(f32|f64)\\b"
247 },
248 {
249 "comment": "Integer literal (decimal)",
250 "name": "constant.numeric.integer.decimal.rust",
251 "match": "\\b[0-9][0-9_]*([ui](8|16|32|64|s|size))?\\b"
252 },
253 {
254 "comment": "Integer literal (hexadecimal)",
255 "name": "constant.numeric.integer.hexadecimal.rust",
256 "match": "\\b0x[a-fA-F0-9_]+([ui](8|16|32|64|s|size))?\\b"
257 },
258 {
259 "comment": "Integer literal (octal)",
260 "name": "constant.numeric.integer.octal.rust",
261 "match": "\\b0o[0-7_]+([ui](8|16|32|64|s|size))?\\b"
262 },
263 {
264 "comment": "Integer literal (binary)",
265 "name": "constant.numeric.integer.binary.rust",
266 "match": "\\b0b[01_]+([ui](8|16|32|64|s|size))?\\b"
267 },
268 {
269 "comment": "Static storage modifier",
270 "name": "storage.modifier.static.rust",
271 "match": "\\bstatic\\b"
272 },
273 {
274 "comment": "Boolean constant",
275 "name": "constant.language.boolean.rust",
276 "match": "\\b(true|false)\\b"
277 },
278 {
279 "comment": "Control keyword",
280 "name": "keyword.control.rust",
281 "match": "\\b(break|continue|else|if|in|for|loop|match|return|while)\\b"
282 },
283 {
284 "comment": "Keyword",
285 "name": "keyword.other.rust",
286 "match": "\\b(crate|extern|mod|let|proc|ref|use|super|as|where|move)\\b"
287 },
288 {
289 "comment": "Unsafe code keyword",
290 "name": "keyword.other.unsafe.rust",
291 "match": "\\bunsafe\\b"
292 },
293 {
294 "include": "#sigils"
295 },
296 {
297 "include": "#self"
298 },
299 {
300 "include": "#mut"
301 },
302 {
303 "include": "#box"
304 },
305 {
306 "include": "#lifetime"
307 },
308 {
309 "include": "#ref_lifetime"
310 },
311 {
312 "include": "#const"
313 },
314 {
315 "include": "#pub"
316 },
317 {
318 "comment": "Miscellaneous operator",
319 "name": "keyword.operator.misc.rust",
320 "match": "(=>|::|\\bas\\b)"
321 },
322 {
323 "comment": "Comparison operator",
324 "name": "keyword.operator.comparison.rust",
325 "match": "(&&|\\|\\||==|!=)"
326 },
327 {
328 "comment": "Assignment operator",
329 "name": "keyword.operator.assignment.rust",
330 "match": "(\\+=|-=|/=|\\*=|%=|\\^=|&=|\\|=|<<=|>>=|=)"
331 },
332 {
333 "comment": "Arithmetic operator",
334 "name": "keyword.operator.arithmetic.rust",
335 "match": "(!|\\+|-|/|\\*|%|\\^|&|\\||<<|>>)"
336 },
337 {
338 "comment": "Comparison operator (second group because of regex precedence)",
339 "name": "keyword.operator.comparison.rust",
340 "match": "(<=|>=|<|>)"
341 },
342 {
343 "include": "#core_types"
344 },
345 {
346 "include": "#core_vars"
347 },
348 {
349 "include": "#core_marker"
350 },
351 {
352 "include": "#core_traits"
353 },
354 {
355 "include": "#std_types"
356 },
357 {
358 "include": "#std_traits"
359 },
360 {
361 "comment": "Built-in macro",
362 "name": "support.function.builtin.rust",
363 "match": "\\b(macro_rules|format_args|env|option_env|concat_idents|concat|log_syntax|line|column|file|stringify|include|include_str|include_bytes|module_path|asm|cfg|trace_macros)!"
364 },
365 {
366 "comment": "Core macro",
367 "name": "support.function.core.rust",
368 "match": "\\b(panic|assert|assert_eq|debug_assert|debug_assert_eq|try|write|writeln|unreachable|unimplemented)!"
369 },
370 {
371 "comment": "Standard library macro",
372 "name": "support.function.std.rust",
373 "match": "\\b(format|print|println|select|vec)!"
374 },
375 {
376 "comment": "Logging macro",
377 "name": "support.function.log.rust",
378 "match": "\\b(log|error|warn|info|debug|trace|log_enabled)!"
379 },
380 {
381 "comment": "Invokation of a macro",
382 "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*\\!)\\s*[({\\[]",
383 "captures": {
384 "1": {
385 "name": "entity.name.function.macro.rust"
386 }
387 }
388 },
389 {
390 "comment": "Function call",
391 "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(",
392 "captures": {
393 "1": {
394 "name": "entity.name.function.rust"
395 }
396 }
397 },
398 {
399 "comment": "Function definition",
400 "begin": "\\b(fn)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
401 "end": "[\\{;]",
402 "beginCaptures": {
403 "1": {
404 "name": "keyword.other.fn.rust"
405 },
406 "2": {
407 "name": "entity.name.function.rust"
408 }
409 },
410 "patterns": [
411 {
412 "include": "#block_comment"
413 },
414 {
415 "include": "#line_comment"
416 },
417 {
418 "include": "#sigils"
419 },
420 {
421 "include": "#self"
422 },
423 {
424 "include": "#mut"
425 },
426 {
427 "include": "#ref_lifetime"
428 },
429 {
430 "include": "#core_types"
431 },
432 {
433 "include": "#core_marker"
434 },
435 {
436 "include": "#core_traits"
437 },
438 {
439 "include": "#std_types"
440 },
441 {
442 "include": "#std_traits"
443 },
444 {
445 "include": "#type_params"
446 },
447 {
448 "include": "#const"
449 },
450 {
451 "include": "#where"
452 }
453 ]
454 },
455 {
456 "comment": "Type declaration",
457 "begin": "\\b(enum|struct|trait)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
458 "end": "[\\{\\(;]",
459 "beginCaptures": {
460 "1": {
461 "name": "storage.type.rust"
462 },
463 "2": {
464 "name": "entity.name.type.rust"
465 }
466 },
467 "patterns": [
468 {
469 "include": "#block_comment"
470 },
471 {
472 "include": "#line_comment"
473 },
474 {
475 "include": "#core_traits"
476 },
477 {
478 "include": "#std_traits"
479 },
480 {
481 "include": "#type_params"
482 },
483 {
484 "include": "#core_types"
485 },
486 {
487 "include": "#pub"
488 },
489 {
490 "include": "#where"
491 }
492 ]
493 },
494 {
495 "comment": "Type alias",
496 "begin": "\\b(type)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
497 "end": ";",
498 "beginCaptures": {
499 "1": {
500 "name": "storage.type.rust"
501 },
502 "2": {
503 "name": "entity.name.type.rust"
504 }
505 },
506 "patterns": [
507 {
508 "include": "#block_comment"
509 },
510 {
511 "include": "#line_comment"
512 },
513 {
514 "include": "#sigils"
515 },
516 {
517 "include": "#mut"
518 },
519 {
520 "include": "#ref_lifetime"
521 },
522 {
523 "include": "#core_types"
524 },
525 {
526 "include": "#core_marker"
527 },
528 {
529 "include": "#core_traits"
530 },
531 {
532 "include": "#std_types"
533 },
534 {
535 "include": "#std_traits"
536 },
537 {
538 "include": "#type_params"
539 }
540 ]
541 },
542 {
543 "comment": "Implementation",
544 "begin": "\\b(impl)\\b",
545 "end": "\\{",
546 "beginCaptures": {
547 "1": {
548 "name": "storage.type.rust"
549 }
550 },
551 "patterns": [
552 {
553 "include": "#block_comment"
554 },
555 {
556 "include": "#line_comment"
557 },
558 {
559 "include": "#sigils"
560 },
561 {
562 "include": "#mut"
563 },
564 {
565 "include": "#ref_lifetime"
566 },
567 {
568 "include": "#core_types"
569 },
570 {
571 "include": "#core_marker"
572 },
573 {
574 "include": "#core_traits"
575 },
576 {
577 "include": "#std_types"
578 },
579 {
580 "include": "#std_traits"
581 },
582 {
583 "include": "#type_params"
584 },
585 {
586 "name": "storage.type.rust",
587 "match": "\\bfor\\b"
588 },
589 {
590 "include": "#where"
591 }
592 ]
593 }
594 ]
595}