Skip to content

Commit 938b7c3

Browse files
AlexanderBrevigmtoohey31
authored andcommitted
fix: close helix-editor#9771 fix comments with ( and ) (helix-editor#9800)
* fix: close helix-editor#9771 update OCaml * fix: no longer match on ( ) as the underlying grammar handles these * fix: implement excellent corrections from review * fix: module -> namespace to match theme scopes
1 parent b45a435 commit 938b7c3

3 files changed

Lines changed: 67 additions & 83 deletions

File tree

languages.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ indent = { tab-width = 2, unit = " " }
10951095

10961096
[[grammar]]
10971097
name = "ocaml"
1098-
source = { git = "https://github.com/tree-sitter/tree-sitter-ocaml", rev = "23d419ba45789c5a47d31448061557716b02750a", subpath = "ocaml" }
1098+
source = { git = "https://github.com/tree-sitter/tree-sitter-ocaml", rev = "9965d208337d88bbf1a38ad0b0fe49e5f5ec9677", subpath = "ocaml" }
10991099

11001100
[[language]]
11011101
name = "ocaml-interface"
@@ -1115,7 +1115,7 @@ indent = { tab-width = 2, unit = " " }
11151115

11161116
[[grammar]]
11171117
name = "ocaml-interface"
1118-
source = { git = "https://github.com/tree-sitter/tree-sitter-ocaml", rev = "23d419ba45789c5a47d31448061557716b02750a", subpath = "interface" }
1118+
source = { git = "https://github.com/tree-sitter/tree-sitter-ocaml", rev = "9965d208337d88bbf1a38ad0b0fe49e5f5ec9677", subpath = "interface" }
11191119

11201120
[[language]]
11211121
name = "lua"

runtime/queries/comment/highlights.scm

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
[
2-
"("
3-
")"
4-
] @punctuation.bracket
5-
61
":" @punctuation.delimiter
72

83
; Hint level tags

runtime/queries/ocaml/highlights.scm

Lines changed: 65 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
; Types
77
;------
88

9-
[(class_name) (class_type_name) (type_constructor)] @type
9+
(
10+
(type_constructor) @type.builtin
11+
(#match? @type.builtin "^(int|char|bytes|string|float|bool|unit|exn|array|list|option|int32|int64|nativeint|format6|lazy_t)$")
12+
)
1013

11-
(type_variable) @type.parameter
14+
[(class_name) (class_type_name) (type_constructor)] @type
1215

1316
[(constructor_name) (tag)] @constructor
1417

@@ -29,27 +32,34 @@
2932

3033
(method_name) @function.method
3134

32-
; Variables
33-
;----------
34-
35-
(value_pattern) @variable.parameter
36-
3735
; Application
3836
;------------
3937

38+
(
39+
(value_name) @function.builtin
40+
(#match? @function.builtin "^(raise(_notrace)?|failwith|invalid_arg)$")
41+
)
42+
4043
(infix_expression
4144
left: (value_path (value_name) @function)
42-
(infix_operator) @operator
45+
operator: (concat_operator) @operator
4346
(#eq? @operator "@@"))
4447

4548
(infix_expression
46-
(infix_operator) @operator
49+
operator: (rel_operator) @operator
4750
right: (value_path (value_name) @function)
4851
(#eq? @operator "|>"))
4952

5053
(application_expression
5154
function: (value_path (value_name) @function))
5255

56+
; Variables
57+
;----------
58+
59+
[(value_name) (type_variable)] @variable
60+
61+
(value_pattern) @variable.parameter
62+
5363
; Properties
5464
;-----------
5565

@@ -58,55 +68,68 @@
5868
; Constants
5969
;----------
6070

61-
[(boolean) (unit)] @constant
62-
63-
[(number) (signed_number)] @constant.numeric.integer
71+
(boolean) @constant.builtin.boolean
6472

65-
(character) @constant.character
73+
[(number) (signed_number)] @constant.numeric
6674

67-
(string) @string
75+
[(string) (character)] @string
6876

6977
(quoted_string "{" @string "}" @string) @string
7078

7179
(escape_sequence) @constant.character.escape
7280

81+
(conversion_specification) @string.special
82+
83+
; Operators
84+
;----------
85+
86+
(match_expression (match_operator) @keyword)
87+
88+
(value_definition [(let_operator) (let_and_operator)] @keyword)
89+
7390
[
74-
(conversion_specification)
75-
(pretty_printing_indication)
76-
] @punctuation.special
91+
(prefix_operator)
92+
(sign_operator)
93+
(pow_operator)
94+
(mult_operator)
95+
(add_operator)
96+
(concat_operator)
97+
(rel_operator)
98+
(and_operator)
99+
(or_operator)
100+
(assign_operator)
101+
(hash_operator)
102+
(indexing_operator)
103+
(let_operator)
104+
(let_and_operator)
105+
(match_operator)
106+
] @operator
107+
108+
["*" "#" "::" "<-"] @operator
77109

78110
; Keywords
79111
;---------
80112

81113
[
82-
"and" "as" "assert" "begin" "class" "constraint"
83-
"end" "external" "in"
84-
"inherit" "initializer" "lazy" "let" "match" "method" "module"
85-
"mutable" "new" "nonrec" "object" "of" "private" "rec" "sig" "struct"
86-
"type" "val" "virtual" "when" "with"
114+
"and" "as" "assert" "begin" "class" "constraint" "do" "done" "downto" "else"
115+
"end" "exception" "external" "for" "fun" "function" "functor" "if" "in"
116+
"include" "inherit" "initializer" "lazy" "let" "match" "method" "module"
117+
"mutable" "new" "nonrec" "object" "of" "open" "private" "rec" "sig" "struct"
118+
"then" "to" "try" "type" "val" "virtual" "when" "while" "with"
87119
] @keyword
88120

89-
["fun" "function" "functor"] @keyword.function
90-
91-
["if" "then" "else"] @keyword.control.conditional
92-
93-
["exception" "try"] @keyword.control.exception
94-
95-
["include" "open"] @keyword.control.import
96-
97-
["for" "to" "downto" "while" "do" "done"] @keyword.control.repeat
121+
; Punctuation
122+
;------------
98123

99-
; Macros
100-
;-------
124+
(attribute ["[@" "]"] @punctuation.special)
125+
(item_attribute ["[@@" "]"] @punctuation.special)
126+
(floating_attribute ["[@@@" "]"] @punctuation.special)
127+
(extension ["[%" "]"] @punctuation.special)
128+
(item_extension ["[%%" "]"] @punctuation.special)
129+
(quoted_extension ["{%" "}"] @punctuation.special)
130+
(quoted_item_extension ["{%%" "}"] @punctuation.special)
101131

102-
(attribute ["[@" "]"] @attribute)
103-
(item_attribute ["[@@" "]"] @attribute)
104-
(floating_attribute ["[@@@" "]"] @attribute)
105-
(extension ["[%" "]"] @function.macro)
106-
(item_extension ["[%%" "]"] @function.macro)
107-
(quoted_extension ["{%" "}"] @function.macro)
108-
(quoted_item_extension ["{%%" "}"] @function.macro)
109-
"%" @function.macro
132+
"%" @punctuation.special
110133

111134
["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>"] @punctuation.bracket
112135

@@ -117,46 +140,12 @@
117140
"->" ";;" ":>" "+=" ":=" ".."
118141
] @punctuation.delimiter
119142

120-
; Operators
121-
;----------
122-
123-
[
124-
(prefix_operator)
125-
(sign_operator)
126-
(infix_operator)
127-
(hash_operator)
128-
(indexing_operator)
129-
(let_operator)
130-
(and_operator)
131-
(match_operator)
132-
] @operator
133-
134-
(match_expression (match_operator) @keyword)
135-
136-
(value_definition [(let_operator) (and_operator)] @keyword)
137-
138-
;; TODO: this is an error now
139-
;(prefix_operator "!" @operator)
140-
141-
(infix_operator ["&" "+" "-" "=" ">" "|" "%"] @operator)
142-
143-
(signed_number ["+" "-"] @operator)
144-
145-
["*" "#" "::" "<-"] @operator
146-
147143
; Attributes
148144
;-----------
149145

150-
(attribute_id) @variable.other.member
146+
(attribute_id) @tag
151147

152148
; Comments
153149
;---------
154150

155151
[(comment) (line_number_directive) (directive) (shebang)] @comment
156-
157-
(ERROR) @error
158-
159-
; Blanket highlights
160-
; ------------------
161-
162-
[(value_name) (type_variable)] @variable

0 commit comments

Comments
 (0)