aboutsummaryrefslogtreecommitdiff
path: root/editors/code/rust.tmGrammar.json
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/rust.tmGrammar.json')
-rw-r--r--editors/code/rust.tmGrammar.json120
1 files changed, 73 insertions, 47 deletions
diff --git a/editors/code/rust.tmGrammar.json b/editors/code/rust.tmGrammar.json
index 3ddd14f9c..1b8cc713a 100644
--- a/editors/code/rust.tmGrammar.json
+++ b/editors/code/rust.tmGrammar.json
@@ -25,6 +25,9 @@
25 }, 25 },
26 "patterns": [ 26 "patterns": [
27 { 27 {
28 "include": "#block-comments"
29 },
30 {
28 "include": "#comments" 31 "include": "#comments"
29 }, 32 },
30 { 33 {
@@ -155,7 +158,7 @@
155 }, 158 },
156 { 159 {
157 "comment": "modules", 160 "comment": "modules",
158 "match": "(mod)\\s+([a-z][A-Za-z0-9_]*)", 161 "match": "(mod)\\s+((?:r#(?!crate|[Ss]elf|super))?[a-z][A-Za-z0-9_]*)",
159 "captures": { 162 "captures": {
160 "1": { 163 "1": {
161 "name": "keyword.control.rust" 164 "name": "keyword.control.rust"
@@ -185,6 +188,9 @@
185 }, 188 },
186 "patterns": [ 189 "patterns": [
187 { 190 {
191 "include": "#block-comments"
192 },
193 {
188 "include": "#comments" 194 "include": "#comments"
189 }, 195 },
190 { 196 {
@@ -212,6 +218,9 @@
212 }, 218 },
213 "patterns": [ 219 "patterns": [
214 { 220 {
221 "include": "#block-comments"
222 },
223 {
215 "include": "#comments" 224 "include": "#comments"
216 }, 225 },
217 { 226 {
@@ -232,6 +241,9 @@
232 ] 241 ]
233 }, 242 },
234 { 243 {
244 "include": "#block-comments"
245 },
246 {
235 "include": "#comments" 247 "include": "#comments"
236 }, 248 },
237 { 249 {
@@ -277,23 +289,17 @@
277 { 289 {
278 "comment": "documentation comments", 290 "comment": "documentation comments",
279 "name": "comment.line.documentation.rust", 291 "name": "comment.line.documentation.rust",
280 "match": "^\\s*///.*", 292 "match": "^\\s*///.*"
281 "patterns": [
282 {
283 "include": "#comments"
284 }
285 ]
286 }, 293 },
287 { 294 {
288 "comment": "line comments", 295 "comment": "line comments",
289 "name": "comment.line.double-slash.rust", 296 "name": "comment.line.double-slash.rust",
290 "match": "\\s*//.*", 297 "match": "\\s*//.*"
291 "patterns": [ 298 }
292 { 299 ]
293 "include": "#comments" 300 },
294 } 301 "block-comments": {
295 ] 302 "patterns": [
296 },
297 { 303 {
298 "comment": "block comments", 304 "comment": "block comments",
299 "name": "comment.block.rust", 305 "name": "comment.block.rust",
@@ -301,7 +307,7 @@
301 "end": "\\*/", 307 "end": "\\*/",
302 "patterns": [ 308 "patterns": [
303 { 309 {
304 "include": "#comments" 310 "include": "#block-comments"
305 } 311 }
306 ] 312 ]
307 }, 313 },
@@ -312,14 +318,9 @@
312 "end": "\\*/", 318 "end": "\\*/",
313 "patterns": [ 319 "patterns": [
314 { 320 {
315 "include": "#comments" 321 "include": "#block-comments"
316 } 322 }
317 ] 323 ]
318 },
319 {
320 "comment": "inferred types, wildcard patterns, ignored params",
321 "name": "comment.char.underscore.rust",
322 "match": "\\b_\\w*\\b"
323 } 324 }
324 ] 325 ]
325 }, 326 },
@@ -426,9 +427,21 @@
426 "functions": { 427 "functions": {
427 "patterns": [ 428 "patterns": [
428 { 429 {
430 "comment": "pub as a function",
431 "match": "\\b(pub)(\\()",
432 "captures": {
433 "1": {
434 "name": "keyword.other.rust"
435 },
436 "2": {
437 "name": "punctuation.brackets.round.rust"
438 }
439 }
440 },
441 {
429 "comment": "function definition", 442 "comment": "function definition",
430 "name": "meta.function.definition.rust", 443 "name": "meta.function.definition.rust",
431 "begin": "\\b(fn)\\s+([A-Za-z0-9_]+)((\\()|(<))", 444 "begin": "\\b(fn)\\s+((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)((\\()|(<))",
432 "beginCaptures": { 445 "beginCaptures": {
433 "1": { 446 "1": {
434 "name": "keyword.control.fn.rust" 447 "name": "keyword.control.fn.rust"
@@ -451,6 +464,9 @@
451 }, 464 },
452 "patterns": [ 465 "patterns": [
453 { 466 {
467 "include": "#block-comments"
468 },
469 {
454 "include": "#comments" 470 "include": "#comments"
455 }, 471 },
456 { 472 {
@@ -494,18 +510,12 @@
494 { 510 {
495 "comment": "function/method calls, chaining", 511 "comment": "function/method calls, chaining",
496 "name": "meta.function.call.rust", 512 "name": "meta.function.call.rust",
497 "begin": "(?:(pub)|(?:(\\.)?([A-Za-z0-9_]+)))(\\()", 513 "begin": "((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)(\\()",
498 "beginCaptures": { 514 "beginCaptures": {
499 "1": { 515 "1": {
500 "name": "keyword.other.rust"
501 },
502 "2": {
503 "name": "keyword.operator.access.dot.rust"
504 },
505 "3": {
506 "name": "entity.name.function.rust" 516 "name": "entity.name.function.rust"
507 }, 517 },
508 "4": { 518 "2": {
509 "name": "punctuation.brackets.round.rust" 519 "name": "punctuation.brackets.round.rust"
510 } 520 }
511 }, 521 },
@@ -517,6 +527,9 @@
517 }, 527 },
518 "patterns": [ 528 "patterns": [
519 { 529 {
530 "include": "#block-comments"
531 },
532 {
520 "include": "#comments" 533 "include": "#comments"
521 }, 534 },
522 { 535 {
@@ -628,10 +641,28 @@
628 }, 641 },
629 { 642 {
630 "comment": "less than, greater than (special case)", 643 "comment": "less than, greater than (special case)",
631 "match": "(^|\\s)(?<!=)([<>])\\s", 644 "match": "(?:\\b|(?:(\\))|(\\])|(\\})))[ \\t]+([<>])[ \\t]+(?:\\b|(?:(\\()|(\\[)|(\\{)))",
632 "captures": { 645 "captures": {
646 "1": {
647 "name": "punctuation.brackets.round.rust"
648 },
633 "2": { 649 "2": {
650 "name": "punctuation.brackets.square.rust"
651 },
652 "3": {
653 "name": "punctuation.brackets.curly.rust"
654 },
655 "4": {
634 "name": "keyword.operator.comparison.rust" 656 "name": "keyword.operator.comparison.rust"
657 },
658 "5": {
659 "name": "punctuation.brackets.round.rust"
660 },
661 "6": {
662 "name": "punctuation.brackets.square.rust"
663 },
664 "7": {
665 "name": "punctuation.brackets.curly.rust"
635 } 666 }
636 } 667 }
637 }, 668 },
@@ -694,23 +725,15 @@
694 "interpolations": { 725 "interpolations": {
695 "comment": "curly brace interpolations", 726 "comment": "curly brace interpolations",
696 "name": "meta.interpolation.rust", 727 "name": "meta.interpolation.rust",
697 "begin": "{", 728 "match": "({)[^\"{}]*(})",
698 "beginCaptures": { 729 "captures": {
699 "0": { 730 "1": {
700 "name": "punctuation.definition.interpolation.rust" 731 "name": "punctuation.definition.interpolation.rust"
701 } 732 },
702 }, 733 "2": {
703 "end": "}",
704 "endCaptures": {
705 "0": {
706 "name": "punctuation.definition.interpolation.rust" 734 "name": "punctuation.definition.interpolation.rust"
707 } 735 }
708 }, 736 }
709 "patterns": [
710 {
711 "include": "#interpolations"
712 }
713 ]
714 }, 737 },
715 "lifetimes": { 738 "lifetimes": {
716 "patterns": [ 739 "patterns": [
@@ -806,6 +829,9 @@
806 }, 829 },
807 "patterns": [ 830 "patterns": [
808 { 831 {
832 "include": "#block-comments"
833 },
834 {
809 "include": "#comments" 835 "include": "#comments"
810 }, 836 },
811 { 837 {
@@ -980,7 +1006,7 @@
980 "name": "punctuation.definition.string.rust" 1006 "name": "punctuation.definition.string.rust"
981 } 1007 }
982 }, 1008 },
983 "end": "(\")(#*)", 1009 "end": "(\")(\\2)",
984 "endCaptures": { 1010 "endCaptures": {
985 "1": { 1011 "1": {
986 "name": "punctuation.definition.string.rust" 1012 "name": "punctuation.definition.string.rust"
@@ -1035,7 +1061,7 @@
1035 { 1061 {
1036 "comment": "variables", 1062 "comment": "variables",
1037 "name": "variable.other.rust", 1063 "name": "variable.other.rust",
1038 "match": "\\b(?<!\\.)[a-z0-9_]+\\b" 1064 "match": "\\b(?<!\\.)(?:r#(?!(crate|[Ss]elf|super)))?[a-z0-9_]+\\b"
1039 } 1065 }
1040 ] 1066 ]
1041 } 1067 }