From f352b98f7e8f5638c83d6b2d9a6bdda89de9bd32 Mon Sep 17 00:00:00 2001 From: Dusty Pomerleau Date: Sat, 24 Oct 2020 13:00:26 +1100 Subject: [PATCH] fix: underscores, raw IDs - remove comment scope from ignored params - underscores will automatically receive variable/param scope - add raw ID syntax to modules, functions, and variables --- editors/code/rust.tmGrammar.json | 33 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/editors/code/rust.tmGrammar.json b/editors/code/rust.tmGrammar.json index f0c5c3cf314..450116df290 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(?