diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-10-24 04:31:17 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-10-24 04:31:17 +0100 |
commit | 4105378dc7479a3dbd39a4afb3eba67d083bd7f8 (patch) | |
tree | ba93767a71f0b4d0eb45f6b335dc122a72208f60 /editors/code | |
parent | 2fa942ad3057bac90869263963daf8b02651d3de (diff) | |
parent | f352b98f7e8f5638c83d6b2d9a6bdda89de9bd32 (diff) |
Merge #6330
6330: Textmate grammar: raw IDs, underscore fixes (closes #6293, #6340) r=dustypomerleau a=dustypomerleau
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6293.
I've included the possibility of the `r#` prefix in:
- function definitions
- function/method calls
- variables/parameters
This way the raw ID will simply get whatever the intended scope was, instead of a unique scope that might be inappropriately themed for its purpose.
Will wait a bit for feedback, in case there are other places you might use raw IDs.
Co-authored-by: Dusty Pomerleau <[email protected]>
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/rust.tmGrammar.json | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/editors/code/rust.tmGrammar.json b/editors/code/rust.tmGrammar.json index f0c5c3cf3..450116df2 100644 --- a/editors/code/rust.tmGrammar.json +++ b/editors/code/rust.tmGrammar.json | |||
@@ -158,7 +158,7 @@ | |||
158 | }, | 158 | }, |
159 | { | 159 | { |
160 | "comment": "modules", | 160 | "comment": "modules", |
161 | "match": "(mod)\\s+([a-z][A-Za-z0-9_]*)", | 161 | "match": "(mod)\\s+((?:r#(?!crate|[Ss]elf|super))?[a-z][A-Za-z0-9_]*)", |
162 | "captures": { | 162 | "captures": { |
163 | "1": { | 163 | "1": { |
164 | "name": "keyword.control.rust" | 164 | "name": "keyword.control.rust" |
@@ -295,11 +295,6 @@ | |||
295 | "comment": "line comments", | 295 | "comment": "line comments", |
296 | "name": "comment.line.double-slash.rust", | 296 | "name": "comment.line.double-slash.rust", |
297 | "match": "\\s*//.*" | 297 | "match": "\\s*//.*" |
298 | }, | ||
299 | { | ||
300 | "comment": "inferred types, wildcard patterns, ignored params", | ||
301 | "name": "comment.char.underscore.rust", | ||
302 | "match": "\\b_\\w*\\b[^!(]" | ||
303 | } | 298 | } |
304 | ] | 299 | ] |
305 | }, | 300 | }, |
@@ -432,9 +427,21 @@ | |||
432 | "functions": { | 427 | "functions": { |
433 | "patterns": [ | 428 | "patterns": [ |
434 | { | 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 | { | ||
435 | "comment": "function definition", | 442 | "comment": "function definition", |
436 | "name": "meta.function.definition.rust", | 443 | "name": "meta.function.definition.rust", |
437 | "begin": "\\b(fn)\\s+([A-Za-z0-9_]+)((\\()|(<))", | 444 | "begin": "\\b(fn)\\s+((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)((\\()|(<))", |
438 | "beginCaptures": { | 445 | "beginCaptures": { |
439 | "1": { | 446 | "1": { |
440 | "name": "keyword.control.fn.rust" | 447 | "name": "keyword.control.fn.rust" |
@@ -503,18 +510,12 @@ | |||
503 | { | 510 | { |
504 | "comment": "function/method calls, chaining", | 511 | "comment": "function/method calls, chaining", |
505 | "name": "meta.function.call.rust", | 512 | "name": "meta.function.call.rust", |
506 | "begin": "(?:(pub)|(?:(\\.)?([A-Za-z0-9_]+)))(\\()", | 513 | "begin": "((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)(\\()", |
507 | "beginCaptures": { | 514 | "beginCaptures": { |
508 | "1": { | 515 | "1": { |
509 | "name": "keyword.other.rust" | ||
510 | }, | ||
511 | "2": { | ||
512 | "name": "keyword.operator.access.dot.rust" | ||
513 | }, | ||
514 | "3": { | ||
515 | "name": "entity.name.function.rust" | 516 | "name": "entity.name.function.rust" |
516 | }, | 517 | }, |
517 | "4": { | 518 | "2": { |
518 | "name": "punctuation.brackets.round.rust" | 519 | "name": "punctuation.brackets.round.rust" |
519 | } | 520 | } |
520 | }, | 521 | }, |
@@ -1042,7 +1043,7 @@ | |||
1042 | { | 1043 | { |
1043 | "comment": "variables", | 1044 | "comment": "variables", |
1044 | "name": "variable.other.rust", | 1045 | "name": "variable.other.rust", |
1045 | "match": "\\b(?<!\\.)[a-z0-9_]+\\b" | 1046 | "match": "\\b(?<!\\.)(?:r#(?!(crate|[Ss]elf|super)))?[a-z0-9_]+\\b" |
1046 | } | 1047 | } |
1047 | ] | 1048 | ] |
1048 | } | 1049 | } |