@@ -0,0 +1,160 @@
1+; Modules
2+;--------
3+
4+[(module_name) (module_type_name)] @namespace
5+
6+; Types
7+;------
8+
9+[(class_name) (class_type_name) (type_constructor)] @type
10+
11+[(constructor_name) (tag)] @constructor
12+
13+; Functions
14+;----------
15+
16+(let_binding
17+ pattern: (value_name) @function
18+ (parameter))
19+
20+(let_binding
21+ pattern: (value_name) @function
22+ body: [(fun_expression) (function_expression)])
23+
24+(value_specification (value_name) @function)
25+
26+(external (value_name) @function)
27+
28+(method_name) @method
29+
30+; Variables
31+;----------
32+
33+(value_pattern) @parameter
34+
35+; Application
36+;------------
37+
38+(infix_expression
39+ left: (value_path (value_name) @function)
40+ (infix_operator) @operator
41+ (#eq? @operator "@@"))
42+
43+(infix_expression
44+ (infix_operator) @operator
45+ right: (value_path (value_name) @function)
46+ (#eq? @operator "|>"))
47+
48+(application_expression
49+ function: (value_path (value_name) @function))
50+
51+; Properties
52+;-----------
53+
54+[(label_name) (field_name) (instance_variable_name)] @property
55+
56+; Constants
57+;----------
58+
59+[(boolean) (unit)] @constant
60+
61+[(number) (signed_number)] @number
62+
63+(character) @character
64+
65+(string) @string
66+
67+(quoted_string "{" @string "}" @string) @string
68+
69+(escape_sequence) @string.escape
70+
71+[
72+ (conversion_specification)
73+ (pretty_printing_indication)
74+] @punctuation.special
75+
76+; Keywords
77+;---------
78+
79+[
80+ "and" "as" "assert" "begin" "class" "constraint"
81+ "end" "external" "in"
82+ "inherit" "initializer" "lazy" "let" "match" "method" "module"
83+ "mutable" "new" "nonrec" "object" "of" "private" "rec" "sig" "struct"
84+ "type" "val" "virtual" "when" "with"
85+] @keyword
86+
87+["fun" "function" "functor"] @keyword.function
88+
89+["if" "then" "else"] @keyword.control.conditional
90+
91+["exception" "try"] @keyword.control.exception
92+
93+["include" "open"] @include
94+
95+["for" "to" "downto" "while" "do" "done"] @keyword.control.loop
96+
97+; Macros
98+;-------
99+
100+(attribute ["[@" "]"] @attribute)
101+(item_attribute ["[@@" "]"] @attribute)
102+(floating_attribute ["[@@@" "]"] @attribute)
103+(extension ["[%" "]"] @function.macro)
104+(item_extension ["[%%" "]"] @function.macro)
105+(quoted_extension ["{%" "}"] @function.macro)
106+(quoted_item_extension ["{%%" "}"] @function.macro)
107+"%" @function.macro
108+
109+["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>"] @punctuation.bracket
110+
111+(object_type ["<" ">"] @punctuation.bracket)
112+
113+[
114+ "," "." ";" ":" "=" "|" "~" "?" "+" "-" "!" ">" "&"
115+ "->" ";;" ":>" "+=" ":=" ".."
116+] @punctuation.delimiter
117+
118+; Operators
119+;----------
120+
121+[
122+ (prefix_operator)
123+ (sign_operator)
124+ (infix_operator)
125+ (hash_operator)
126+ (indexing_operator)
127+ (let_operator)
128+ (and_operator)
129+ (match_operator)
130+] @operator
131+
132+(match_expression (match_operator) @keyword)
133+
134+(value_definition [(let_operator) (and_operator)] @keyword)
135+
136+;; TODO: this is an error now
137+;(prefix_operator "!" @operator)
138+
139+(infix_operator ["&" "+" "-" "=" ">" "|" "%"] @operator)
140+
141+(signed_number ["+" "-"] @operator)
142+
143+["*" "#" "::" "<-"] @operator
144+
145+; Attributes
146+;-----------
147+
148+(attribute_id) @property
149+
150+; Comments
151+;---------
152+
153+[(comment) (line_number_directive) (directive) (shebang)] @comment
154+
155+(ERROR) @error
156+
157+; Blanket highlights
158+; ------------------
159+
160+[(value_name) (type_variable)] @variable