From 6d64d94332b674c2f187eb9b012b1f4bb9698eae Mon Sep 17 00:00:00 2001 From: Max Lantas Date: Sat, 29 Aug 2020 11:28:40 -0700 Subject: [PATCH 1/4] highlight label with type in ocaml --- syntaxes/ocaml.interface.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/ocaml.interface.json b/syntaxes/ocaml.interface.json index c87a83386..f0920514e 100644 --- a/syntaxes/ocaml.interface.json +++ b/syntaxes/ocaml.interface.json @@ -25,7 +25,7 @@ { "comment": "labeled argument", "name": "variable.parameter.labeled.ocaml", - "match": "~[[:lower:]_][[:word:]']*" + "match": "~([[:lower:]_][[:word:]']*)?" }, { "comment": "module type of", From e1cf0f1cc5ba53491850423711ccabf6ebdee528 Mon Sep 17 00:00:00 2001 From: Max Lantas Date: Sat, 29 Aug 2020 11:36:01 -0700 Subject: [PATCH 2/4] handle brackets inside of attributes/extensions --- syntaxes/ocaml.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/syntaxes/ocaml.json b/syntaxes/ocaml.json index 3f0094500..7e44cae82 100644 --- a/syntaxes/ocaml.json +++ b/syntaxes/ocaml.json @@ -530,6 +530,24 @@ "comment": "empty array", "name": "constant.language.ocaml strong", "match": "\\[\\|\\|\\]" + }, + { + "comment": "array", + "begin": "\\[\\|", + "end": "\\|\\]", + "patterns": [{ "include": "$self" }] + }, + + { + "comment": "empty list", + "name": "constant.language.ocaml strong", + "match": "\\[\\]" + }, + { + "comment": "list", + "begin": "\\[", + "end": "]", + "patterns": [{ "include": "$self" }] } ] }, From a4c4a91660447e4050cf1db63360b89632dac266 Mon Sep 17 00:00:00 2001 From: Max Lantas Date: Sat, 29 Aug 2020 11:42:50 -0700 Subject: [PATCH 3/4] update change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 372dd3aab..62fd2dc1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Highlight method keyword in ocaml interface (#340) - Add support for opam template file (#342) +- Improve highlighting of labels and attributes/extensions in OCaml files (#343) ## 1.0.0 From b6859a5d99da75abd254f97b597752c9003af238 Mon Sep 17 00:00:00 2001 From: Max Lantas Date: Sat, 29 Aug 2020 12:05:31 -0700 Subject: [PATCH 4/4] highlight label names inside of parentheses --- syntaxes/ocaml.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/syntaxes/ocaml.json b/syntaxes/ocaml.json index 7e44cae82..80e906ab1 100644 --- a/syntaxes/ocaml.json +++ b/syntaxes/ocaml.json @@ -379,6 +379,26 @@ "3": { "name": "entity.name.function.binding.ocaml" } } }, + { + "comment": "optional labeled argument with type", + "begin": "(\\?)\\([[:space:]]*([[:lower:]_][[:word:]']*)", + "beginCaptures": { + "1": { "name": "variable.parameter.optional.ocaml" }, + "2": { "name": "variable.parameter.optional.ocaml" } + }, + "end": "\\)", + "patterns": [{ "include": "$self" }] + }, + { + "comment": "labeled argument with type", + "begin": "(~)\\([[:space:]]*([[:lower:]_][[:word:]']*)", + "beginCaptures": { + "1": { "name": "variable.parameter.labeled.ocaml" }, + "2": { "name": "variable.parameter.labeled.ocaml" } + }, + "end": "\\)", + "patterns": [{ "include": "$self" }] + }, { "include": "source.ocaml.interface#bindings" } ] }, @@ -525,6 +545,12 @@ "name": "constant.language.ocaml strong", "match": "\\(\\)" }, + { + "comment": "parentheses", + "begin": "\\(", + "end": "\\)", + "patterns": [{ "include": "$self" }] + }, { "comment": "empty array",