Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

ocaml: Improve highlighting and bracketing (#20700)

lord794ad1af75d3
diff --git a/extensions/ocaml/languages/ocaml-interface/brackets.scm b/extensions/ocaml/languages/ocaml-interface/brackets.scm
index f05821c17cc..e7e8145eba1 100644
--- a/extensions/ocaml/languages/ocaml-interface/brackets.scm
+++ b/extensions/ocaml/languages/ocaml-interface/brackets.scm
@@ -1,3 +1,2 @@
("(" @open ")" @close)
("{" @open "}" @close)
-("<" @open ">" @close)
diff --git a/extensions/ocaml/languages/ocaml-interface/config.toml b/extensions/ocaml/languages/ocaml-interface/config.toml
index a1efdf18df2..a4378ec3edb 100644
--- a/extensions/ocaml/languages/ocaml-interface/config.toml
+++ b/extensions/ocaml/languages/ocaml-interface/config.toml
@@ -2,11 +2,10 @@ name = "OCaml Interface"
code_fence_block_name = "ocaml"
grammar = "ocaml_interface"
path_suffixes = ["mli"]
-block_comment = ["(* ", "*)"]
+block_comment = ["(* ", " *)"]
autoclose_before = ";,=)}"
brackets = [
{ start = "{", end = "}", close = true, newline = true },
- { start = "<", end = ">", close = true, newline = true },
{ start = "[", end = "]", close = true, newline = true },
{ start = "(", end = ")", close = true, newline = true }
]
diff --git a/extensions/ocaml/languages/ocaml/brackets.scm b/extensions/ocaml/languages/ocaml/brackets.scm
index 269d87778d7..1f5ee9bfa34 100644
--- a/extensions/ocaml/languages/ocaml/brackets.scm
+++ b/extensions/ocaml/languages/ocaml/brackets.scm
@@ -2,5 +2,4 @@
("[" @open "]" @close)
("[|" @open "|]" @close)
("{" @open "}" @close)
-("<" @open ">" @close)
("\"" @open "\"" @close)
diff --git a/extensions/ocaml/languages/ocaml/config.toml b/extensions/ocaml/languages/ocaml/config.toml
index 2cd81bde52c..7d5b4348d66 100644
--- a/extensions/ocaml/languages/ocaml/config.toml
+++ b/extensions/ocaml/languages/ocaml/config.toml
@@ -1,11 +1,11 @@
name = "OCaml"
grammar = "ocaml"
path_suffixes = ["ml"]
-block_comment = ["(* ", "*)"]
+block_comment = ["(* ", " *)"]
autoclose_before = ";,=)}]"
brackets = [
{ start = "{", end = "}", close = true, newline = true },
- { start = "<", end = ">", close = true, newline = true },
+ { start = "{|", end = "|", close = true, newline = true, not_in = ["string"] },
{ start = "[", end = "]", close = true, newline = true },
{ start = "[|", end = "|", close = true, newline = true, not_in = ["string"] },
{ start = "(", end = ")", close = true, newline = true },
diff --git a/extensions/ocaml/languages/ocaml/highlights.scm b/extensions/ocaml/languages/ocaml/highlights.scm
index 6623e1e5435..8029d3cc22e 100644
--- a/extensions/ocaml/languages/ocaml/highlights.scm
+++ b/extensions/ocaml/languages/ocaml/highlights.scm
@@ -44,12 +44,27 @@
; Variables
;----------
-[(type_variable) (value_pattern)] @variable
+(value_pattern) @variable
+
+(type_variable) @variable.special
; Properties
;-----------
-[(label_name) (field_name) (instance_variable_name)] @property
+[(field_name) (instance_variable_name)] @property
+
+; Labels
+;-------
+
+[(label_name) (parameter)] @label
+
+(parameter
+ pattern: (value_pattern) @label)
+; despite the above rule, we should still label value_pattern as a variable
+; when a label name is present
+(parameter
+ (label_name)
+ pattern: (value_pattern) @variable)
; Constants
;----------
@@ -112,7 +127,7 @@
; Punctuation
;------------
-["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>"] @punctuation.bracket
+["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>" "[@@" "[@" "[%"] @punctuation.bracket
(object_type ["<" ">"] @punctuation.bracket)
@@ -132,7 +147,7 @@
(item_extension)
(quoted_extension)
(quoted_item_extension)
- "%"
+
] @attribute
(attribute_id) @tag