@@ -25,6 +25,8 @@ contexts:
25
25
26
26
statements :
27
27
28
+ - include : visibility
29
+
28
30
- match : ' ;'
29
31
scope : punctuation.terminator
30
32
@@ -36,11 +38,10 @@ contexts:
36
38
- match : ' '' {{identifier}}(?!\'' )\b'
37
39
scope : storage.modifier.lifetime.rust
38
40
39
- - match : ' \b(?:(pub)\s+)?\b( mod)\s+({{identifier}})\b'
41
+ - match : ' \b(mod)\s+({{identifier}})\b'
40
42
captures :
41
- 1 : storage.modifier.rust
42
- 2 : storage.type.module.rust
43
- 3 : entity.name.module.rust
43
+ 1 : storage.type.module.rust
44
+ 2 : entity.name.module.rust
44
45
push :
45
46
- meta_scope : meta.module.rust
46
47
- match : ' ;'
@@ -53,44 +54,34 @@ contexts:
53
54
2 : keyword.operator.rust
54
55
push : closure
55
56
56
- - match : ' \b(?:(pub)\s+)?\b(fn)\s+(?={{identifier}})'
57
- scope : meta.function.rust
57
+ - match : ' \b(fn)\s+(?={{identifier}})'
58
58
captures :
59
- 1 : storage.modifier.rust
60
- 2 : storage.type.function.rust
59
+ 1 : storage.type.function.rust
61
60
push : fn-definition
62
61
63
- - match : ' \b(?:(pub)\s+)?(struct)\s+'
64
- scope : meta.struct.rust
65
- captures :
66
- 1 : storage.modifier.rust
67
- 2 : storage.type.struct.rust
62
+ - match : ' \bstruct\b'
63
+ scope : storage.type.struct.rust
68
64
push : struct-identifier
69
65
70
- - match : ' \b(?:(pub)\s+)?(union)\s+'
71
- scope : meta.union.rust
72
- captures :
73
- 1 : storage.modifier.rust
74
- 2 : storage.type.union.rust
66
+ - match : ' \bunion\b'
67
+ scope : storage.type.union.rust
75
68
push : union-identifier
76
69
77
- - match : ' \b(?:(pub)\s+)?( type)\s+({{identifier}})\b'
70
+ - match : ' \b(type)\s+({{identifier}})\b'
78
71
captures :
79
- 1 : storage.modifier.rust
80
- 2 : storage.type.type.rust
81
- 3 : entity.name.type.rust
72
+ 1 : storage.type.type.rust
73
+ 2 : entity.name.type.rust
82
74
push :
83
75
- match : ' =(?!=)'
84
76
scope : keyword.operator.rust
85
77
push : after-operator
86
78
- match : ' (?=\S)'
87
79
pop : true
88
80
89
- - match : ' \b(?:(pub)\s+)?( trait)\s+({{identifier}})\b'
81
+ - match : ' \b(trait)\s+({{identifier}})\b'
90
82
captures :
91
- 1 : storage.modifier.rust
92
- 2 : storage.type.trait.rust
93
- 3 : entity.name.trait.rust
83
+ 1 : storage.type.trait.rust
84
+ 2 : entity.name.trait.rust
94
85
push :
95
86
- meta_scope : meta.trait.rust
96
87
- include : statements-block
@@ -99,11 +90,10 @@ contexts:
99
90
scope : storage.type.impl.rust
100
91
push : impl-definition
101
92
102
- - match : ' \b(?:(pub)\s+)?( enum)\s+({{identifier}})\b'
93
+ - match : ' \b(enum)\s+({{identifier}})\b'
103
94
captures :
104
- 1 : storage.modifier.rust
105
- 2 : storage.type.enum.rust
106
- 3 : entity.name.enum.rust
95
+ 1 : storage.type.enum.rust
96
+ 2 : entity.name.enum.rust
107
97
push :
108
98
- meta_scope : meta.enum.rust
109
99
- include : statements-block
@@ -260,6 +250,25 @@ contexts:
260
250
- match : ' [-=<>&|!~@?+*/%^'' #$]'
261
251
scope : keyword.operator.rust
262
252
253
+ visibility :
254
+ - match : ' \b(pub)\s*(\()'
255
+ captures :
256
+ 1 : storage.modifier.rust
257
+ 2 : punctuation.definition.group.begin.rust
258
+ push :
259
+ - include : comments
260
+ - match : ' \)'
261
+ scope : punctuation.definition.group.end.rust
262
+ pop : true
263
+ - match : ' (crate|in|self|super)'
264
+ scope : keyword.other.rust
265
+ - match : ' ::'
266
+ scope : meta.path.rust
267
+ - match : ' {{identifier}}'
268
+ scope : meta.path.rust
269
+ - match : ' \bpub\b'
270
+ scope : storage.modifier.rust
271
+
263
272
attribute :
264
273
- match : ' #!?\['
265
274
push :
@@ -506,6 +515,7 @@ contexts:
506
515
scope : keyword.operator.rust
507
516
508
517
struct-identifier :
518
+ - meta_scope : meta.struct.rust
509
519
- match : ' {{identifier}}(?=<)'
510
520
scope : entity.name.struct.rust
511
521
set :
@@ -537,14 +547,12 @@ contexts:
537
547
pop : true
538
548
- match : ' \('
539
549
scope : punctuation.definition.group.begin.rust
540
- # Ensure that we end the tuple at the next ) to
541
- # prevent odd highlighting as the user is typing
542
- with_prototype :
550
+ push :
543
551
- match : ' (?=\))'
544
552
pop : true
545
- push :
546
553
- meta_scope : meta.group.rust
547
554
- include : comments
555
+ - include : visibility
548
556
- include : type-any-identifier
549
557
550
558
struct-classic :
@@ -562,8 +570,7 @@ contexts:
562
570
pop : true
563
571
- include : comments
564
572
- include : attribute
565
- - match : \bpub\b
566
- scope : storage.modifier.rust
573
+ - include : visibility
567
574
- match : ' {{identifier}}(?=\s*:)'
568
575
scope : variable.other.member.rust
569
576
push :
@@ -576,6 +583,7 @@ contexts:
576
583
577
584
578
585
union-identifier :
586
+ - meta_scope : meta.union.rust
579
587
- match : ' {{identifier}}(?=<)'
580
588
scope : entity.name.union.rust
581
589
set :
0 commit comments