From 2d8924e03cf669d538a4bd2b0e8dd2001a75154b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Falisz?= Date: Mon, 22 Feb 2021 22:31:58 +0100 Subject: [PATCH 1/9] Add type, external, let word coloring && unit as constant --- grammars/rescript.tmLanguage.json | 56 ++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index 014bd7259..ade8f40c5 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -21,6 +21,10 @@ "name": "constant.language", "match": "\\b(true|false)\\b" }, + "RE_UNIT": { + "name": "constant.language", + "match": "\\(\\)" + }, "commentLine": { "match": "//.*", "name": "comment.line" @@ -98,6 +102,9 @@ "patterns": [ { "include": "#RE_LITERAL" + }, + { + "include": "#RE_UNIT" } ] }, @@ -430,6 +437,46 @@ ] } ] + }, + "variable-declaration": { + "patterns": [ + { + "match": "(?<=external )[a-z][a-z_A-Z_0-9_]*", + "name": "entity.name.function" + }, + { + "match": "(?<=let )[a-z][a-z_A-Z_0-9_]*", + "name": "entity.name.function" + }, + + { + "match": "(?<=let rec )[a-z][a-z_A-Z_0-9_]*", + "name": "entity.name.function" + }, + + { + "match": "(?<=let )[_][a-z][a-z_A-Z_0-9_]*", + "name": "comment" + } + ] + }, + "type-declaration": { + "patterns": [ + { + "match": "(?<=type )\\b[a-z][a-z_A-Z_0-9_]*", + "name": "entity.name.function" + }, + + { + "match": "(?<=and )\\b[a-z][a-z_A-Z_0-9_]*", + "name": "entity.name.function" + }, + + { + "match": "(?<=type rec )[a-z][a-z_A-Z_0-9_]*", + "name": "entity.name.function" + } + ] } }, "patterns": [ @@ -469,6 +516,10 @@ { "include": "#jsx" }, + { + "include": "#jsx-attributes" + }, + { "include": "#operator" }, @@ -492,6 +543,9 @@ }, { "include": "#punctuations" - } + }, + + { "include": "#type-declaration" }, + { "include": "#variable-declaration" } ] } From ec8c44061c26a93772fcd12f687152544db14897 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 31 Mar 2021 17:04:58 -0700 Subject: [PATCH 2/9] Remove invalid jsx-attributes include --- grammars/rescript.tmLanguage.json | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index ade8f40c5..8c27e55b4 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -448,12 +448,10 @@ "match": "(?<=let )[a-z][a-z_A-Z_0-9_]*", "name": "entity.name.function" }, - { "match": "(?<=let rec )[a-z][a-z_A-Z_0-9_]*", "name": "entity.name.function" }, - { "match": "(?<=let )[_][a-z][a-z_A-Z_0-9_]*", "name": "comment" @@ -466,12 +464,10 @@ "match": "(?<=type )\\b[a-z][a-z_A-Z_0-9_]*", "name": "entity.name.function" }, - { "match": "(?<=and )\\b[a-z][a-z_A-Z_0-9_]*", "name": "entity.name.function" }, - { "match": "(?<=type rec )[a-z][a-z_A-Z_0-9_]*", "name": "entity.name.function" @@ -516,10 +512,6 @@ { "include": "#jsx" }, - { - "include": "#jsx-attributes" - }, - { "include": "#operator" }, @@ -544,8 +536,11 @@ { "include": "#punctuations" }, - - { "include": "#type-declaration" }, - { "include": "#variable-declaration" } + { + "include": "#type-declaration" + }, + { + "include": "#variable-declaration" + } ] } From bdd2a44af732634405ab6cb246e4d564abfdfc6f Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 31 Mar 2021 17:05:47 -0700 Subject: [PATCH 3/9] Remove `()` highlighted as constant It's technically a constant but I think if the parentheses in `f()` and `let f = () => 1` are highlighted but not `f(a)` and `let f = (a) => 1`, then it's confusing. The elegance of `()` being "just" a regular value in ocaml (which isn't even true; it's already a special piece of syntax) doesn't translate well here and nor should we highlight said elegance when the analogy with function parens is stretched that thin. --- grammars/rescript.tmLanguage.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index 8c27e55b4..acf9d6905 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -21,10 +21,6 @@ "name": "constant.language", "match": "\\b(true|false)\\b" }, - "RE_UNIT": { - "name": "constant.language", - "match": "\\(\\)" - }, "commentLine": { "match": "//.*", "name": "comment.line" @@ -102,9 +98,6 @@ "patterns": [ { "include": "#RE_LITERAL" - }, - { - "include": "#RE_UNIT" } ] }, From fff4a6ca7da7e6bad90174e3e4429190c2591151 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 31 Mar 2021 17:06:38 -0700 Subject: [PATCH 4/9] Remove highlighing `_foo` binding as comment `_foo` can actually be used as a value, so highlighting it as a comment is very misleading. Imagine seeing that greyed out, removing it, and seeing a type error. We can potentially highlight `_`, because that's genuinely not usable as a value, except we VSCode/textmate doesn't have a good scope for it... --- grammars/rescript.tmLanguage.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index acf9d6905..79d646f78 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -444,10 +444,6 @@ { "match": "(?<=let rec )[a-z][a-z_A-Z_0-9_]*", "name": "entity.name.function" - }, - { - "match": "(?<=let )[_][a-z][a-z_A-Z_0-9_]*", - "name": "comment" } ] }, From 1dbfc17d740af0a7c38c088781ea3a4c93c3d973 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 31 Mar 2021 17:07:01 -0700 Subject: [PATCH 5/9] Fix regexes --- grammars/rescript.tmLanguage.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index 79d646f78..b9b97674d 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -434,15 +434,15 @@ "variable-declaration": { "patterns": [ { - "match": "(?<=external )[a-z][a-z_A-Z_0-9_]*", + "match": "(?<=external )[a-z_][0-9a-zA-Z_]*", "name": "entity.name.function" }, { - "match": "(?<=let )[a-z][a-z_A-Z_0-9_]*", + "match": "(?<=let )[a-z_][0-9a-zA-Z_]*", "name": "entity.name.function" }, { - "match": "(?<=let rec )[a-z][a-z_A-Z_0-9_]*", + "match": "(?<=let rec )[a-z_][0-9a-zA-Z_]*", "name": "entity.name.function" } ] @@ -450,15 +450,15 @@ "type-declaration": { "patterns": [ { - "match": "(?<=type )\\b[a-z][a-z_A-Z_0-9_]*", + "match": "(?<=type )[a-z_][0-9a-zA-Z_]*", "name": "entity.name.function" }, { - "match": "(?<=and )\\b[a-z][a-z_A-Z_0-9_]*", + "match": "(?<=and )[a-z_][0-9a-zA-Z_]*", "name": "entity.name.function" }, { - "match": "(?<=type rec )[a-z][a-z_A-Z_0-9_]*", + "match": "(?<=type rec )[a-z_][0-9a-zA-Z_]*", "name": "entity.name.function" } ] From f48b5f02688646024b1937d2592a86b7dd3a7d61 Mon Sep 17 00:00:00 2001 From: Pawel Falisz Date: Sat, 5 Jun 2021 18:29:15 +0200 Subject: [PATCH 6/9] Highlight record property --- grammars/rescript.tmLanguage.json | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index b9b97674d..2e22baf20 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -431,7 +431,7 @@ } ] }, - "variable-declaration": { + "variableDeclaration": { "patterns": [ { "match": "(?<=external )[a-z_][0-9a-zA-Z_]*", @@ -447,7 +447,7 @@ } ] }, - "type-declaration": { + "typeDeclaration": { "patterns": [ { "match": "(?<=type )[a-z_][0-9a-zA-Z_]*", @@ -462,6 +462,14 @@ "name": "entity.name.function" } ] + }, + "recordProperty": { + "patterns": [ + { + "name": "variable.object.property", + "match": "([a-z_][0-9a-zA-Z_]*(?=:))" + } + ] } }, "patterns": [ @@ -526,10 +534,10 @@ "include": "#punctuations" }, { - "include": "#type-declaration" + "include": "#typeDeclaration" }, { - "include": "#variable-declaration" + "include": "#variableDeclaration" } ] } From 09f7385efd428da71175365458bb4a7821b50e27 Mon Sep 17 00:00:00 2001 From: Pawel Falisz Date: Sat, 5 Jun 2021 18:44:08 +0200 Subject: [PATCH 7/9] Include record property --- grammars/rescript.tmLanguage.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index 2e22baf20..410ac95d0 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -538,6 +538,9 @@ }, { "include": "#variableDeclaration" + }, + { + "include": "#recordProperty" } ] } From 399bb45c4c2f0754829c05e0ad79340b81fc2257 Mon Sep 17 00:00:00 2001 From: Pawel Falisz Date: Sat, 5 Jun 2021 18:55:59 +0200 Subject: [PATCH 8/9] Better color pol variant in dark+ and one dark pro --- grammars/rescript.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index 410ac95d0..d46f2525e 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -224,7 +224,7 @@ "name": "punctuation.definition.keyword" }, "3": { - "name": "variable.function variable.other" + "name": "variable.function variable.other variable.other.enummember constant.other.symbol" } } } From e9dab02c8a7d96770140462ab2a64b0354b475e0 Mon Sep 17 00:00:00 2001 From: Pawel Falisz Date: Sat, 5 Jun 2021 19:15:44 +0200 Subject: [PATCH 9/9] Hack punctuation --- grammars/rescript.tmLanguage.json | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index d46f2525e..1fa324d95 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -51,31 +51,27 @@ }, { "match": "\\,", - "name": "punctuation.separator" + "name": "constant.character punctuation.separator" }, { "match": "\\?|:", - "name": "punctuation.separator" - }, - { - "match": "\\|(?!\\|)", - "name": "punctuation.separator" + "name": "constant.character punctuation.separator" }, { "match": "\\{", - "name": "punctuation.section.braces.begin" + "name": "constant.character punctuation.section.braces.begin" }, { "match": "\\}", - "name": "punctuation.section.braces.end" + "name": "constant.character punctuation.section.braces.end" }, { "match": "\\(", - "name": "punctuation.section.parens.begin" + "name": "constant.character punctuation.section.parens.begin" }, { "match": "\\)", - "name": "punctuation.section.parens.end" + "name": "constant.character punctuation.section.parens.end" } ] }, @@ -234,11 +230,11 @@ "patterns": [ { "match": "\\[", - "name": "punctuation.section.brackets.begin" + "name": "constant.character punctuation.section.brackets.begin" }, { "match": "\\]", - "name": "punctuation.section.brackets.end" + "name": "constant.character punctuation.section.brackets.end" } ] }, @@ -251,13 +247,13 @@ "name": "keyword" }, "2": { - "name": "punctuation.section.braces.begin" + "name": "constant.character punctuation.section.braces.begin" } } }, { "match": "\\}", - "name": "punctuation.section.braces.end" + "name": "constant.character punctuation.section.braces.end" } ] }, @@ -267,13 +263,13 @@ "match": "\\b[a-z_][0-9a-zA-Z_]*(\\[)", "captures": { "1": { - "name": "punctuation.section.brackets.begin" + "name": "constant.character punctuation.section.brackets.begin" } } }, { "match": "\\]", - "name": "punctuation.section.brackets.end" + "name": "constant.character punctuation.section.brackets.end" } ] },