[OCaml] Mobile-friendly clone of cgit.
1
{
2
"information_for_contributors":[
3
"This file has been converted from https://github.com/dustypomerleau/rust-syntax/blob/master/syntaxes/rust.tmLanguage.json",
4
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
5
"Once accepted there, we are happy to receive an update request."
6
],
7
"version":"https://github.com/dustypomerleau/rust-syntax/commit/268fd42cfd4aa96a6ed9024a2850d17d6cd2dc7b",
8
"name":"Rust",
9
"scopeName":"source.rust",
10
"patterns":[
11
{
12
"comment":"boxed slice literal",
13
"begin":"(<)(\\[)",
14
"beginCaptures":{
15
"1":{
16
"name":"punctuation.brackets.angle.rust"
17
},
18
"2":{
19
"name":"punctuation.brackets.square.rust"
20
}
21
},
22
"end":">",
23
"endCaptures":{
24
"0":{
25
"name":"punctuation.brackets.angle.rust"
26
}
27
},
28
"patterns":[
29
{
30
"include":"#block-comments"
31
},
32
{
33
"include":"#comments"
34
},
35
{
36
"include":"#gtypes"
37
},
38
{
39
"include":"#lvariables"
40
},
41
{
42
"include":"#lifetimes"
43
},
44
{
45
"include":"#punctuation"
46
},
47
{
48
"include":"#types"
49
}
50
]
51
},
52
{
53
"comment":"macro type metavariables",
54
"name":"meta.macro.metavariable.type.rust",
55
"match":"(\\$)((crate)|([A-Z]\\w*))(\\s*(:)\\s*(block|expr(?:_2021)?|ident|item|lifetime|literal|meta|pat(?:_param)?|path|stmt|tt|ty|vis)\\b)?",
56
"captures":{
57
"1":{
58
"name":"keyword.operator.macro.dollar.rust"
59
},
60
"3":{
61
"name":"keyword.other.crate.rust"
62
},
63
"4":{
64
"name":"entity.name.type.metavariable.rust"
65
},
66
"6":{
67
"name":"keyword.operator.key-value.rust"
68
},
69
"7":{
70
"name":"variable.other.metavariable.specifier.rust"
71
}
72
},
73
"patterns":[
74
{
75
"include":"#keywords"
76
}
77
]
78
},
79
{
80
"comment":"macro metavariables",
81
"name":"meta.macro.metavariable.rust",
82
"match":"(\\$)([a-z]\\w*)(\\s*(:)\\s*(block|expr(?:_2021)?|ident|item|lifetime|literal|meta|pat(?:_param)?|path|stmt|tt|ty|vis)\\b)?",
83
"captures":{
84
"1":{
85
"name":"keyword.operator.macro.dollar.rust"
86
},
87
"2":{
88
"name":"variable.other.metavariable.name.rust"
89
},
90
"4":{
91
"name":"keyword.operator.key-value.rust"
92
},
93
"5":{
94
"name":"variable.other.metavariable.specifier.rust"
95
}
96
},
97
"patterns":[
98
{
99
"include":"#keywords"
100
}
101
]
102
},
103
{
104
"comment":"macro rules",
105
"name":"meta.macro.rules.rust",
106
"match":"\\b(macro_rules!)\\s+(([a-z0-9_]+)|([A-Z][a-z0-9_]*))\\s+(\\{)",
107
"captures":{
108
"1":{
109
"name":"entity.name.function.macro.rules.rust"
110
},
111
"3":{
112
"name":"entity.name.function.macro.rust"
113
},
114
"4":{
115
"name":"entity.name.type.macro.rust"
116
},
117
"5":{
118
"name":"punctuation.brackets.curly.rust"
119
}
120
}
121
},
122
{
123
"comment":"modules",
124
"match":"(mod)\\s+((?:r#(?!crate|[Ss]elf|super))?[a-z][A-Za-z0-9_]*)",
125
"captures":{
126
"1":{
127
"name":"storage.type.rust"
128
},
129
"2":{
130
"name":"entity.name.module.rust"
131
}
132
}
133
},
134
{
135
"comment":"external crate imports",
136
"name":"meta.import.rust",
137
"begin":"\\b(extern)\\s+(crate)",
138
"beginCaptures":{
139
"1":{
140
"name":"storage.type.rust"
141
},
142
"2":{
143
"name":"keyword.other.crate.rust"
144
}
145
},
146
"end":";",
147
"endCaptures":{
148
"0":{
149
"name":"punctuation.semi.rust"
150
}
151
},
152
"patterns":[
153
{
154
"include":"#block-comments"
155
},
156
{
157
"include":"#comments"
158
},
159
{
160
"include":"#keywords"
161
},
162
{
163
"include":"#punctuation"
164
}
165
]
166
},
167
{
168
"comment":"use statements",
169
"name":"meta.use.rust",
170
"begin":"\\b(use)\\s",
171
"beginCaptures":{
172
"1":{
173
"name":"keyword.other.rust"
174
}
175
},
176
"end":";",
177
"endCaptures":{
178
"0":{
179
"name":"punctuation.semi.rust"
180
}
181
},
182
"patterns":[
183
{
184
"include":"#block-comments"
185
},
186
{
187
"include":"#comments"
188
},
189
{
190
"include":"#keywords"
191
},
192
{
193
"include":"#namespaces"
194
},
195
{
196
"include":"#punctuation"
197
},
198
{
199
"include":"#types"
200
},
201
{
202
"include":"#lvariables"
203
}
204
]
205
},
206
{
207
"include":"#block-comments"
208
},
209
{
210
"include":"#comments"
211
},
212
{
213
"include":"#attributes"
214
},
215
{
216
"include":"#lvariables"
217
},
218
{
219
"include":"#constants"
220
},
221
{
222
"include":"#gtypes"
223
},
224
{
225
"include":"#functions"
226
},
227
{
228
"include":"#types"
229
},
230
{
231
"include":"#keywords"
232
},
233
{
234
"include":"#lifetimes"
235
},
236
{
237
"include":"#macros"
238
},
239
{
240
"include":"#namespaces"
241
},
242
{
243
"include":"#punctuation"
244
},
245
{
246
"include":"#strings"
247
},
248
{
249
"include":"#variables"
250
}
251
],
252
"repository":{
253
"comments":{
254
"patterns":[
255
{
256
"comment":"documentation comments",
257
"name":"comment.line.documentation.rust",
258
"match":"(///).*$",
259
"captures":{
260
"1":{
261
"name":"punctuation.definition.comment.rust"
262
}
263
}
264
},
265
{
266
"comment":"line comments",
267
"name":"comment.line.double-slash.rust",
268
"match":"(//).*$",
269
"captures":{
270
"1":{
271
"name":"punctuation.definition.comment.rust"
272
}
273
}
274
}
275
]
276
},
277
"block-comments":{
278
"patterns":[
279
{
280
"comment":"empty block comments",
281
"name":"comment.block.rust",
282
"match":"/\\*\\*/"
283
},
284
{
285
"comment":"block documentation comments",
286
"name":"comment.block.documentation.rust",
287
"begin":"/\\*\\*",
288
"end":"\\*/",
289
"patterns":[
290
{
291
"include":"#block-comments"
292
}
293
]
294
},
295
{
296
"comment":"block comments",
297
"name":"comment.block.rust",
298
"begin":"/\\*(?!\\*)",
299
"end":"\\*/",
300
"patterns":[
301
{
302
"include":"#block-comments"
303
}
304
]
305
}
306
]
307
},
308
"constants":{
309
"patterns":[
310
{
311
"comment":"ALL CAPS constants",
312
"name":"constant.other.caps.rust",
313
"match":"\\b[A-Z]{2}[A-Z0-9_]*\\b"
314
},
315
{
316
"comment":"constant declarations",
317
"match":"\\b(const)\\s+([A-Z][A-Za-z0-9_]*)\\b",
318
"captures":{
319
"1":{
320
"name":"storage.type.rust"
321
},
322
"2":{
323
"name":"constant.other.caps.rust"
324
}
325
}
326
},
327
{
328
"comment":"decimal integers and floats",
329
"name":"constant.numeric.decimal.rust",
330
"match":"\\b\\d[\\d_]*(\\.?)[\\d_]*(?:(E|e)([+-]?)([\\d_]+))?(f32|f64|i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b",
331
"captures":{
332
"1":{
333
"name":"punctuation.separator.dot.decimal.rust"
334
},
335
"2":{
336
"name":"keyword.operator.exponent.rust"
337
},
338
"3":{
339
"name":"keyword.operator.exponent.sign.rust"
340
},
341
"4":{
342
"name":"constant.numeric.decimal.exponent.mantissa.rust"
343
},
344
"5":{
345
"name":"entity.name.type.numeric.rust"
346
}
347
}
348
},
349
{
350
"comment":"hexadecimal integers",
351
"name":"constant.numeric.hex.rust",
352
"match":"\\b0x[\\da-fA-F_]+(i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b",
353
"captures":{
354
"1":{
355
"name":"entity.name.type.numeric.rust"
356
}
357
}
358
},
359
{
360
"comment":"octal integers",
361
"name":"constant.numeric.oct.rust",
362
"match":"\\b0o[0-7_]+(i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b",
363
"captures":{
364
"1":{
365
"name":"entity.name.type.numeric.rust"
366
}
367
}
368
},
369
{
370
"comment":"binary integers",
371
"name":"constant.numeric.bin.rust",
372
"match":"\\b0b[01_]+(i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b",
373
"captures":{
374
"1":{
375
"name":"entity.name.type.numeric.rust"
376
}
377
}
378
},
379
{
380
"comment":"booleans",
381
"name":"constant.language.bool.rust",
382
"match":"\\b(true|false)\\b"
383
}
384
]
385
},
386
"escapes":{
387
"comment":"escapes: ASCII, byte, Unicode, quote, regex",
388
"name":"constant.character.escape.rust",
389
"match":"(\\\\)(?:(?:(x[0-7][\\da-fA-F])|(u(\\{)[\\da-fA-F]{4,6}(\\}))|.))",
390
"captures":{
391
"1":{
392
"name":"constant.character.escape.backslash.rust"
393
},
394
"2":{
395
"name":"constant.character.escape.bit.rust"
396
},
397
"3":{
398
"name":"constant.character.escape.unicode.rust"
399
},
400
"4":{
401
"name":"constant.character.escape.unicode.punctuation.rust"
402
},
403
"5":{
404
"name":"constant.character.escape.unicode.punctuation.rust"
405
}
406
}
407
},
408
"attributes":{
409
"comment":"attributes",
410
"name":"meta.attribute.rust",
411
"begin":"(#)(\\!?)(\\[)",
412
"beginCaptures":{
413
"1":{
414
"name":"punctuation.definition.attribute.rust"
415
},
416
"3":{
417
"name":"punctuation.brackets.attribute.rust"
418
}
419
},
420
"end":"\\]",
421
"endCaptures":{
422
"0":{
423
"name":"punctuation.brackets.attribute.rust"
424
}
425
},
426
"patterns":[
427
{
428
"include":"#block-comments"
429
},
430
{
431
"include":"#comments"
432
},
433
{
434
"include":"#keywords"
435
},
436
{
437
"include":"#lifetimes"
438
},
439
{
440
"include":"#punctuation"
441
},
442
{
443
"include":"#strings"
444
},
445
{
446
"include":"#gtypes"
447
},
448
{
449
"include":"#types"
450
}
451
]
452
},
453
"functions":{
454
"patterns":[
455
{
456
"comment":"pub as a function",
457
"match":"\\b(pub)(\\()",
458
"captures":{
459
"1":{
460
"name":"keyword.other.rust"
461
},
462
"2":{
463
"name":"punctuation.brackets.round.rust"
464
}
465
}
466
},
467
{
468
"comment":"function definition",
469
"name":"meta.function.definition.rust",
470
"begin":"\\b(fn)\\s+((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)((\\()|(<))",
471
"beginCaptures":{
472
"1":{
473
"name":"keyword.other.fn.rust"
474
},
475
"2":{
476
"name":"entity.name.function.rust"
477
},
478
"4":{
479
"name":"punctuation.brackets.round.rust"
480
},
481
"5":{
482
"name":"punctuation.brackets.angle.rust"
483
}
484
},
485
"end":"(\\{)|(;)",
486
"endCaptures":{
487
"1":{
488
"name":"punctuation.brackets.curly.rust"
489
},
490
"2":{
491
"name":"punctuation.semi.rust"
492
}
493
},
494
"patterns":[
495
{
496
"include":"#block-comments"
497
},
498
{
499
"include":"#comments"
500
},
501
{
502
"include":"#keywords"
503
},
504
{
505
"include":"#lvariables"
506
},
507
{
508
"include":"#constants"
509
},
510
{
511
"include":"#gtypes"
512
},
513
{
514
"include":"#functions"
515
},
516
{
517
"include":"#lifetimes"
518
},
519
{
520
"include":"#macros"
521
},
522
{
523
"include":"#namespaces"
524
},
525
{
526
"include":"#punctuation"
527
},
528
{
529
"include":"#strings"
530
},
531
{
532
"include":"#types"
533
},
534
{
535
"include":"#variables"
536
}
537
]
538
},
539
{
540
"comment":"function/method calls, chaining",
541
"name":"meta.function.call.rust",
542
"begin":"((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)(\\()",
543
"beginCaptures":{
544
"1":{
545
"name":"entity.name.function.rust"
546
},
547
"2":{
548
"name":"punctuation.brackets.round.rust"
549
}
550
},
551
"end":"\\)",
552
"endCaptures":{
553
"0":{
554
"name":"punctuation.brackets.round.rust"
555
}
556
},
557
"patterns":[
558
{
559
"include":"#block-comments"
560
},
561
{
562
"include":"#comments"
563
},
564
{
565
"include":"#attributes"
566
},
567
{
568
"include":"#keywords"
569
},
570
{
571
"include":"#lvariables"
572
},
573
{
574
"include":"#constants"
575
},
576
{
577
"include":"#gtypes"
578
},
579
{
580
"include":"#functions"
581
},
582
{
583
"include":"#lifetimes"
584
},
585
{
586
"include":"#macros"
587
},
588
{
589
"include":"#namespaces"
590
},
591
{
592
"include":"#punctuation"
593
},
594
{
595
"include":"#strings"
596
},
597
{
598
"include":"#types"
599
},
600
{
601
"include":"#variables"
602
}
603
]
604
},
605
{
606
"comment":"function/method calls with turbofish",
607
"name":"meta.function.call.rust",
608
"begin":"((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)(?=::<.*>\\()",
609
"beginCaptures":{
610
"1":{
611
"name":"entity.name.function.rust"
612
}
613
},
614
"end":"\\)",
615
"endCaptures":{
616
"0":{
617
"name":"punctuation.brackets.round.rust"
618
}
619
},
620
"patterns":[
621
{
622
"include":"#block-comments"
623
},
624
{
625
"include":"#comments"
626
},
627
{
628
"include":"#attributes"
629
},
630
{
631
"include":"#keywords"
632
},
633
{
634
"include":"#lvariables"
635
},
636
{
637
"include":"#constants"
638
},
639
{
640
"include":"#gtypes"
641
},
642
{
643
"include":"#functions"
644
},
645
{
646
"include":"#lifetimes"
647
},
648
{
649
"include":"#macros"
650
},
651
{
652
"include":"#namespaces"
653
},
654
{
655
"include":"#punctuation"
656
},
657
{
658
"include":"#strings"
659
},
660
{
661
"include":"#types"
662
},
663
{
664
"include":"#variables"
665
}
666
]
667
}
668
]
669
},
670
"keywords":{
671
"patterns":[
672
{
673
"comment":"control flow keywords",
674
"name":"keyword.control.rust",
675
"match":"\\b(await|break|continue|do|else|for|if|loop|match|return|try|while|yield)\\b"
676
},
677
{
678
"comment":"storage keywords",
679
"name":"keyword.other.rust storage.type.rust",
680
"match":"\\b(extern|let|macro|mod)\\b"
681
},
682
{
683
"comment":"const keyword",
684
"name":"storage.modifier.rust",
685
"match":"\\b(const)\\b"
686
},
687
{
688
"comment":"type keyword",
689
"name":"keyword.declaration.type.rust storage.type.rust",
690
"match":"\\b(type)\\b"
691
},
692
{
693
"comment":"enum keyword",
694
"name":"keyword.declaration.enum.rust storage.type.rust",
695
"match":"\\b(enum)\\b"
696
},
697
{
698
"comment":"trait keyword",
699
"name":"keyword.declaration.trait.rust storage.type.rust",
700
"match":"\\b(trait)\\b"
701
},
702
{
703
"comment":"struct keyword",
704
"name":"keyword.declaration.struct.rust storage.type.rust",
705
"match":"\\b(struct)\\b"
706
},
707
{
708
"comment":"storage modifiers",
709
"name":"storage.modifier.rust",
710
"match":"\\b(abstract|static)\\b"
711
},
712
{
713
"comment":"other keywords",
714
"name":"keyword.other.rust",
715
"match":"\\b(as|async|become|box|dyn|move|final|gen|impl|in|override|priv|pub|ref|typeof|union|unsafe|unsized|use|virtual|where)\\b"
716
},
717
{
718
"comment":"fn",
719
"name":"keyword.other.fn.rust",
720
"match":"\\bfn\\b"
721
},
722
{
723
"comment":"crate",
724
"name":"keyword.other.crate.rust",
725
"match":"\\bcrate\\b"
726
},
727
{
728
"comment":"mut",
729
"name":"storage.modifier.mut.rust",
730
"match":"\\bmut\\b"
731
},
732
{
733
"comment":"logical operators",
734
"name":"keyword.operator.logical.rust",
735
"match":"(\\^|\\||\\|\\||&&|<<|>>|!)(?!=)"
736
},
737
{
738
"comment":"logical AND, borrow references",
739
"name":"keyword.operator.borrow.and.rust",
740
"match":"&(?![&=])"
741
},
742
{
743
"comment":"assignment operators",
744
"name":"keyword.operator.assignment.rust",
745
"match":"(\\+=|-=|\\*=|/=|%=|\\^=|&=|\\|=|<<=|>>=)"
746
},
747
{
748
"comment":"single equal",
749
"name":"keyword.operator.assignment.equal.rust",
750
"match":"(?<![<>])=(?!=|>)"
751
},
752
{
753
"comment":"comparison operators",
754
"name":"keyword.operator.comparison.rust",
755
"match":"(=(=)?(?!>)|!=|<=|(?<!=)>=)"
756
},
757
{
758
"comment":"math operators",
759
"name":"keyword.operator.math.rust",
760
"match":"(([+%]|(\\*(?!\\w)))(?!=))|(-(?!>))|(/(?!/))"
761
},
762
{
763
"comment":"less than, greater than (special case)",
764
"match":"(?:\\b|(?:(\\))|(\\])|(\\})))[ \\t]+([<>])[ \\t]+(?:\\b|(?:(\\()|(\\[)|(\\{)))",
765
"captures":{
766
"1":{
767
"name":"punctuation.brackets.round.rust"
768
},
769
"2":{
770
"name":"punctuation.brackets.square.rust"
771
},
772
"3":{
773
"name":"punctuation.brackets.curly.rust"
774
},
775
"4":{
776
"name":"keyword.operator.comparison.rust"
777
},
778
"5":{
779
"name":"punctuation.brackets.round.rust"
780
},
781
"6":{
782
"name":"punctuation.brackets.square.rust"
783
},
784
"7":{
785
"name":"punctuation.brackets.curly.rust"
786
}
787
}
788
},
789
{
790
"comment":"namespace operator",
791
"name":"keyword.operator.namespace.rust",
792
"match":"::"
793
},
794
{
795
"comment":"dereference asterisk",
796
"match":"(\\*)(?=\\w+)",
797
"captures":{
798
"1":{
799
"name":"keyword.operator.dereference.rust"
800
}
801
}
802
},
803
{
804
"comment":"subpattern binding",
805
"name":"keyword.operator.subpattern.rust",
806
"match":"@"
807
},
808
{
809
"comment":"dot access",
810
"name":"keyword.operator.access.dot.rust",
811
"match":"\\.(?!\\.)"
812
},
813
{
814
"comment":"ranges, range patterns",
815
"name":"keyword.operator.range.rust",
816
"match":"\\.{2}(=|\\.)?"
817
},
818
{
819
"comment":"colon",
820
"name":"keyword.operator.key-value.rust",
821
"match":":(?!:)"
822
},
823
{
824
"comment":"dashrocket, skinny arrow",
825
"name":"keyword.operator.arrow.skinny.rust",
826
"match":"->|<-"
827
},
828
{
829
"comment":"hashrocket, fat arrow",
830
"name":"keyword.operator.arrow.fat.rust",
831
"match":"=>"
832
},
833
{
834
"comment":"dollar macros",
835
"name":"keyword.operator.macro.dollar.rust",
836
"match":"\\$"
837
},
838
{
839
"comment":"question mark operator, questionably sized, macro kleene matcher",
840
"name":"keyword.operator.question.rust",
841
"match":"\\?"
842
}
843
]
844
},
845
"interpolations":{
846
"comment":"curly brace interpolations",
847
"name":"meta.interpolation.rust",
848
"match":"({)[^\"{}]*(})",
849
"captures":{
850
"1":{
851
"name":"punctuation.definition.interpolation.rust"
852
},
853
"2":{
854
"name":"punctuation.definition.interpolation.rust"
855
}
856
}
857
},
858
"lifetimes":{
859
"patterns":[
860
{
861
"comment":"named lifetime parameters",
862
"match":"(['])([a-zA-Z_][0-9a-zA-Z_]*)(?!['])\\b",
863
"captures":{
864
"1":{
865
"name":"punctuation.definition.lifetime.rust"
866
},
867
"2":{
868
"name":"entity.name.type.lifetime.rust"
869
}
870
}
871
},
872
{
873
"comment":"borrowing references to named lifetimes",
874
"match":"(\\&)(['])([a-zA-Z_][0-9a-zA-Z_]*)(?!['])\\b",
875
"captures":{
876
"1":{
877
"name":"keyword.operator.borrow.rust"
878
},
879
"2":{
880
"name":"punctuation.definition.lifetime.rust"
881
},
882
"3":{
883
"name":"entity.name.type.lifetime.rust"
884
}
885
}
886
}
887
]
888
},
889
"macros":{
890
"patterns":[
891
{
892
"comment":"macros",
893
"name":"meta.macro.rust",
894
"match":"(([a-z_][A-Za-z0-9_]*!)|([A-Z_][A-Za-z0-9_]*!))",
895
"captures":{
896
"2":{
897
"name":"entity.name.function.macro.rust"
898
},
899
"3":{
900
"name":"entity.name.type.macro.rust"
901
}
902
}
903
}
904
]
905
},
906
"namespaces":{
907
"patterns":[
908
{
909
"comment":"namespace (non-type, non-function path segment)",
910
"match":"(?<![A-Za-z0-9_])([A-Za-z0-9_]+)((?<!super|self)::)",
911
"captures":{
912
"1":{
913
"name":"entity.name.namespace.rust"
914
},
915
"2":{
916
"name":"keyword.operator.namespace.rust"
917
}
918
}
919
}
920
]
921
},
922
"types":{
923
"patterns":[
924
{
925
"comment":"numeric types",
926
"match":"(?<![A-Za-z])(f32|f64|i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)\\b",
927
"captures":{
928
"1":{
929
"name":"entity.name.type.numeric.rust"
930
}
931
}
932
},
933
{
934
"comment":"parameterized types",
935
"begin":"\\b(_?[A-Z][A-Za-z0-9_]*)(<)",
936
"beginCaptures":{
937
"1":{
938
"name":"entity.name.type.rust"
939
},
940
"2":{
941
"name":"punctuation.brackets.angle.rust"
942
}
943
},
944
"end":">",
945
"endCaptures":{
946
"0":{
947
"name":"punctuation.brackets.angle.rust"
948
}
949
},
950
"patterns":[
951
{
952
"include":"#block-comments"
953
},
954
{
955
"include":"#comments"
956
},
957
{
958
"include":"#keywords"
959
},
960
{
961
"include":"#lvariables"
962
},
963
{
964
"include":"#lifetimes"
965
},
966
{
967
"include":"#punctuation"
968
},
969
{
970
"include":"#types"
971
},
972
{
973
"include":"#variables"
974
}
975
]
976
},
977
{
978
"comment":"primitive types",
979
"name":"entity.name.type.primitive.rust",
980
"match":"\\b(bool|char|str)\\b"
981
},
982
{
983
"comment":"trait declarations",
984
"match":"\\b(trait)\\s+(_?[A-Z][A-Za-z0-9_]*)\\b",
985
"captures":{
986
"1":{
987
"name":"keyword.declaration.trait.rust storage.type.rust"
988
},
989
"2":{
990
"name":"entity.name.type.trait.rust"
991
}
992
}
993
},
994
{
995
"comment":"struct declarations",
996
"match":"\\b(struct)\\s+(_?[A-Z][A-Za-z0-9_]*)\\b",
997
"captures":{
998
"1":{
999
"name":"keyword.declaration.struct.rust storage.type.rust"
1000
},
1001
"2":{
1002
"name":"entity.name.type.struct.rust"
1003
}
1004
}
1005
},
1006
{
1007
"comment":"enum declarations",
1008
"match":"\\b(enum)\\s+(_?[A-Z][A-Za-z0-9_]*)\\b",
1009
"captures":{
1010
"1":{
1011
"name":"keyword.declaration.enum.rust storage.type.rust"
1012
},
1013
"2":{
1014
"name":"entity.name.type.enum.rust"
1015
}
1016
}
1017
},
1018
{
1019
"comment":"type declarations",
1020
"match":"\\b(type)\\s+(_?[A-Z][A-Za-z0-9_]*)\\b",
1021
"captures":{
1022
"1":{
1023
"name":"keyword.declaration.type.rust storage.type.rust"
1024
},
1025
"2":{
1026
"name":"entity.name.type.declaration.rust"
1027
}
1028
}
1029
},
1030
{
1031
"comment":"types",
1032
"name":"entity.name.type.rust",
1033
"match":"\\b_?[A-Z][A-Za-z0-9_]*\\b(?!!)"
1034
}
1035
]
1036
},
1037
"gtypes":{
1038
"patterns":[
1039
{
1040
"comment":"option types",
1041
"name":"entity.name.type.option.rust",
1042
"match":"\\b(Some|None)\\b"
1043
},
1044
{
1045
"comment":"result types",
1046
"name":"entity.name.type.result.rust",
1047
"match":"\\b(Ok|Err)\\b"
1048
}
1049
]
1050
},
1051
"punctuation":{
1052
"patterns":[
1053
{
1054
"comment":"comma",
1055
"name":"punctuation.comma.rust",
1056
"match":","
1057
},
1058
{
1059
"comment":"curly braces",
1060
"name":"punctuation.brackets.curly.rust",
1061
"match":"[{}]"
1062
},
1063
{
1064
"comment":"parentheses, round brackets",
1065
"name":"punctuation.brackets.round.rust",
1066
"match":"[()]"
1067
},
1068
{
1069
"comment":"semicolon",
1070
"name":"punctuation.semi.rust",
1071
"match":";"
1072
},
1073
{
1074
"comment":"square brackets",
1075
"name":"punctuation.brackets.square.rust",
1076
"match":"[\\[\\]]"
1077
},
1078
{
1079
"comment":"angle brackets",
1080
"name":"punctuation.brackets.angle.rust",
1081
"match":"(?<!=)[<>]"
1082
}
1083
]
1084
},
1085
"strings":{
1086
"patterns":[
1087
{
1088
"comment":"double-quoted strings and byte strings",
1089
"name":"string.quoted.double.rust",
1090
"begin":"(b?)(\")",
1091
"beginCaptures":{
1092
"1":{
1093
"name":"string.quoted.byte.raw.rust"
1094
},
1095
"2":{
1096
"name":"punctuation.definition.string.rust"
1097
}
1098
},
1099
"end":"\"",
1100
"endCaptures":{
1101
"0":{
1102
"name":"punctuation.definition.string.rust"
1103
}
1104
},
1105
"patterns":[
1106
{
1107
"include":"#escapes"
1108
},
1109
{
1110
"include":"#interpolations"
1111
}
1112
]
1113
},
1114
{
1115
"comment":"double-quoted raw strings and raw byte strings",
1116
"name":"string.quoted.double.rust",
1117
"begin":"(b?r)(#*)(\")",
1118
"beginCaptures":{
1119
"1":{
1120
"name":"string.quoted.byte.raw.rust"
1121
},
1122
"2":{
1123
"name":"punctuation.definition.string.raw.rust"
1124
},
1125
"3":{
1126
"name":"punctuation.definition.string.rust"
1127
}
1128
},
1129
"end":"(\")(\\2)",
1130
"endCaptures":{
1131
"1":{
1132
"name":"punctuation.definition.string.rust"
1133
},
1134
"2":{
1135
"name":"punctuation.definition.string.raw.rust"
1136
}
1137
}
1138
},
1139
{
1140
"comment":"characters and bytes",
1141
"name":"string.quoted.single.char.rust",
1142
"begin":"(b)?(')",
1143
"beginCaptures":{
1144
"1":{
1145
"name":"string.quoted.byte.raw.rust"
1146
},
1147
"2":{
1148
"name":"punctuation.definition.char.rust"
1149
}
1150
},
1151
"end":"'",
1152
"endCaptures":{
1153
"0":{
1154
"name":"punctuation.definition.char.rust"
1155
}
1156
},
1157
"patterns":[
1158
{
1159
"include":"#escapes"
1160
}
1161
]
1162
}
1163
]
1164
},
1165
"lvariables":{
1166
"patterns":[
1167
{
1168
"comment":"self",
1169
"name":"variable.language.self.rust",
1170
"match":"\\b[Ss]elf\\b"
1171
},
1172
{
1173
"comment":"super",
1174
"name":"variable.language.super.rust",
1175
"match":"\\bsuper\\b"
1176
}
1177
]
1178
},
1179
"variables":{
1180
"patterns":[
1181
{
1182
"comment":"variables",
1183
"name":"variable.other.rust",
1184
"match":"\\b(?<!(?<!\\.)\\.)(?:r#(?!(crate|[Ss]elf|super)))?[a-z0-9_]+\\b"
1185
}
1186
]
1187
}
1188
}
1189
}