diff --git a/editors/code/rust.tmGrammar.json b/editors/code/rust.tmGrammar.json index f0c5c3cf31..450116df29 100644 --- a/editors/code/rust.tmGrammar.json +++ b/editors/code/rust.tmGrammar.json @@ -158,7 +158,7 @@ }, { "comment": "modules", - "match": "(mod)\\s+([a-z][A-Za-z0-9_]*)", + "match": "(mod)\\s+((?:r#(?!crate|[Ss]elf|super))?[a-z][A-Za-z0-9_]*)", "captures": { "1": { "name": "keyword.control.rust" @@ -295,11 +295,6 @@ "comment": "line comments", "name": "comment.line.double-slash.rust", "match": "\\s*//.*" - }, - { - "comment": "inferred types, wildcard patterns, ignored params", - "name": "comment.char.underscore.rust", - "match": "\\b_\\w*\\b[^!(]" } ] }, @@ -431,10 +426,22 @@ }, "functions": { "patterns": [ + { + "comment": "pub as a function", + "match": "\\b(pub)(\\()", + "captures": { + "1": { + "name": "keyword.other.rust" + }, + "2": { + "name": "punctuation.brackets.round.rust" + } + } + }, { "comment": "function definition", "name": "meta.function.definition.rust", - "begin": "\\b(fn)\\s+([A-Za-z0-9_]+)((\\()|(<))", + "begin": "\\b(fn)\\s+((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)((\\()|(<))", "beginCaptures": { "1": { "name": "keyword.control.fn.rust" @@ -503,18 +510,12 @@ { "comment": "function/method calls, chaining", "name": "meta.function.call.rust", - "begin": "(?:(pub)|(?:(\\.)?([A-Za-z0-9_]+)))(\\()", + "begin": "((?:r#(?!crate|[Ss]elf|super))?[A-Za-z0-9_]+)(\\()", "beginCaptures": { "1": { - "name": "keyword.other.rust" - }, - "2": { - "name": "keyword.operator.access.dot.rust" - }, - "3": { "name": "entity.name.function.rust" }, - "4": { + "2": { "name": "punctuation.brackets.round.rust" } }, @@ -1042,7 +1043,7 @@ { "comment": "variables", "name": "variable.other.rust", - "match": "\\b(?