Skip to content

Commit 575a1b5

Browse files
re-classify keywords (control, storage, other); bundle bangs into macros
1 parent 8ab2761 commit 575a1b5

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

editors/code/rust.tmGrammar.json

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,18 @@
9898
{
9999
"comment": "macro rules",
100100
"name": "meta.macro.rules.rust",
101-
"match": "\\b(macro_rules)(!)\\s+(([a-z0-9_]+)|([A-Z][a-z0-9_]*))\\s+(\\{)",
101+
"match": "\\b(macro_rules!)\\s+(([a-z0-9_]+)|([A-Z][a-z0-9_]*))\\s+(\\{)",
102102
"captures": {
103103
"1": {
104-
"name": "entity.name.function.macro.rust"
104+
"name": "entity.name.function.macro.rules.rust"
105105
},
106-
"2": {
107-
"name": "keyword.operator.macro.not.rust"
106+
"3": {
107+
"name": "entity.name.function.macro.rust"
108108
},
109109
"4": {
110-
"name": "entity.name.function.rust"
111-
},
112-
"5": {
113110
"name": "entity.name.type.macro.rust"
114111
},
115-
"6": {
112+
"5": {
116113
"name": "punctuation.brackets.curly.rust"
117114
}
118115
}
@@ -564,7 +561,22 @@
564561
{
565562
"comment": "control flow keywords",
566563
"name": "keyword.control.rust",
567-
"match": "\\b(abstract|as|async|await|become|box|break|const|continue|do|dyn|else|enum|extern|final|for|if|impl|in|let|loop|macro|match|mod|move|override|priv|pub|ref|return|static|struct|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\\b"
564+
"match": "\\b(async|await|break|continue|do|else|for|if|loop|match|move|return|try|where|while|yield)\\b"
565+
},
566+
{
567+
"comment": "storage keywords",
568+
"name": "storage.type.rust",
569+
"match": "\\b(const|enum|extern|let|macro|mod|struct|trait|type)\\b"
570+
},
571+
{
572+
"comment": "storage modifiers",
573+
"name": "storage.modifier.rust",
574+
"match": "\\b(abstract|static)\\b"
575+
},
576+
{
577+
"comment": "other keywords",
578+
"name": "keyword.other.rust",
579+
"match": "\\b(as|become|box|dyn|final|impl|in|override|priv|pub|ref|typeof|union|unsafe|unsized|use|virtual)\\b"
568580
},
569581
{
570582
"comment": "pub as a function",
@@ -580,7 +592,7 @@
580592
},
581593
{
582594
"comment": "fn",
583-
"name": "keyword.control.fn.rust",
595+
"name": "keyword.other.fn.rust",
584596
"match": "\\bfn\\b"
585597
},
586598
{
@@ -590,7 +602,7 @@
590602
},
591603
{
592604
"comment": "mut",
593-
"name": "keyword.other.mut.rust",
605+
"name": "storage.modifier.mut.rust",
594606
"match": "\\bmut\\b"
595607
},
596608
{
@@ -601,12 +613,7 @@
601613
{
602614
"comment": "logical operators",
603615
"name": "keyword.operator.logical.rust",
604-
"match": "(\\^|\\||\\|\\||&&|<<|>>)(?!=)"
605-
},
606-
{
607-
"comment": "macro bang and not",
608-
"name": "keyword.operator.macro.not.rust",
609-
"match": "!(?!=)"
616+
"match": "(\\^|\\||\\|\\||&&|<<|>>|!)(?!=)"
610617
},
611618
{
612619
"comment": "logical AND, borrow references",
@@ -652,7 +659,7 @@
652659
}
653660
},
654661
{
655-
"comment": "subpattern bindng",
662+
"comment": "subpattern binding",
656663
"name": "keyword.operator.subpattern.rust",
657664
"match": "@"
658665
},
@@ -750,16 +757,13 @@
750757
{
751758
"comment": "macros",
752759
"name": "meta.macro.rust",
753-
"match": "(([a-z_][A-Za-z0-9_]*)|([A-Z_][A-Za-z0-9_]*))(!)",
760+
"match": "(([a-z_][A-Za-z0-9_]*!)|([A-Z_][A-Za-z0-9_]*!))",
754761
"captures": {
755762
"2": {
756763
"name": "entity.name.function.macro.rust"
757764
},
758765
"3": {
759766
"name": "entity.name.type.macro.rust"
760-
},
761-
"4": {
762-
"name": "keyword.operator.macro.not.rust"
763767
}
764768
}
765769
}
@@ -843,7 +847,7 @@
843847
"match": "\\b(trait)\\s+([A-Z][A-Za-z0-9]*)\\b",
844848
"captures": {
845849
"1": {
846-
"name": "keyword.control.rust"
850+
"name": "storage.type.rust"
847851
},
848852
"2": {
849853
"name": "entity.name.type.trait.rust"
@@ -855,7 +859,7 @@
855859
"match": "\\b(struct)\\s+([A-Z][A-Za-z0-9]*)\\b",
856860
"captures": {
857861
"1": {
858-
"name": "keyword.control.rust"
862+
"name": "storage.type.rust"
859863
},
860864
"2": {
861865
"name": "entity.name.type.struct.rust"
@@ -867,7 +871,7 @@
867871
"match": "\\b(enum)\\s+([A-Z][A-Za-z0-9_]*)\\b",
868872
"captures": {
869873
"1": {
870-
"name": "keyword.control.rust"
874+
"name": "storage.type.rust"
871875
},
872876
"2": {
873877
"name": "entity.name.type.enum.rust"
@@ -879,7 +883,7 @@
879883
"match": "\\b(type)\\s+([A-Z][A-Za-z0-9_]*)\\b",
880884
"captures": {
881885
"1": {
882-
"name": "keyword.control.rust"
886+
"name": "storage.type.rust"
883887
},
884888
"2": {
885889
"name": "entity.name.type.declaration.rust"

0 commit comments

Comments
 (0)