|
6 | 6 | ; Types |
7 | 7 | ;------ |
8 | 8 |
|
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 | +) |
10 | 13 |
|
11 | | -(type_variable) @type.parameter |
| 14 | +[(class_name) (class_type_name) (type_constructor)] @type |
12 | 15 |
|
13 | 16 | [(constructor_name) (tag)] @constructor |
14 | 17 |
|
|
29 | 32 |
|
30 | 33 | (method_name) @function.method |
31 | 34 |
|
32 | | -; Variables |
33 | | -;---------- |
34 | | - |
35 | | -(value_pattern) @variable.parameter |
36 | | - |
37 | 35 | ; Application |
38 | 36 | ;------------ |
39 | 37 |
|
| 38 | +( |
| 39 | + (value_name) @function.builtin |
| 40 | + (#match? @function.builtin "^(raise(_notrace)?|failwith|invalid_arg)$") |
| 41 | +) |
| 42 | + |
40 | 43 | (infix_expression |
41 | 44 | left: (value_path (value_name) @function) |
42 | | - (infix_operator) @operator |
| 45 | + operator: (concat_operator) @operator |
43 | 46 | (#eq? @operator "@@")) |
44 | 47 |
|
45 | 48 | (infix_expression |
46 | | - (infix_operator) @operator |
| 49 | + operator: (rel_operator) @operator |
47 | 50 | right: (value_path (value_name) @function) |
48 | 51 | (#eq? @operator "|>")) |
49 | 52 |
|
50 | 53 | (application_expression |
51 | 54 | function: (value_path (value_name) @function)) |
52 | 55 |
|
| 56 | +; Variables |
| 57 | +;---------- |
| 58 | + |
| 59 | +[(value_name) (type_variable)] @variable |
| 60 | + |
| 61 | +(value_pattern) @variable.parameter |
| 62 | + |
53 | 63 | ; Properties |
54 | 64 | ;----------- |
55 | 65 |
|
|
58 | 68 | ; Constants |
59 | 69 | ;---------- |
60 | 70 |
|
61 | | -[(boolean) (unit)] @constant |
62 | | - |
63 | | -[(number) (signed_number)] @constant.numeric.integer |
| 71 | +(boolean) @constant.builtin.boolean |
64 | 72 |
|
65 | | -(character) @constant.character |
| 73 | +[(number) (signed_number)] @constant.numeric |
66 | 74 |
|
67 | | -(string) @string |
| 75 | +[(string) (character)] @string |
68 | 76 |
|
69 | 77 | (quoted_string "{" @string "}" @string) @string |
70 | 78 |
|
71 | 79 | (escape_sequence) @constant.character.escape |
72 | 80 |
|
| 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 | + |
73 | 90 | [ |
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 |
77 | 109 |
|
78 | 110 | ; Keywords |
79 | 111 | ;--------- |
80 | 112 |
|
81 | 113 | [ |
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" |
87 | 119 | ] @keyword |
88 | 120 |
|
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 | +;------------ |
98 | 123 |
|
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) |
101 | 131 |
|
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 |
110 | 133 |
|
111 | 134 | ["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>"] @punctuation.bracket |
112 | 135 |
|
|
117 | 140 | "->" ";;" ":>" "+=" ":=" ".." |
118 | 141 | ] @punctuation.delimiter |
119 | 142 |
|
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 | | - |
147 | 143 | ; Attributes |
148 | 144 | ;----------- |
149 | 145 |
|
150 | | -(attribute_id) @variable.other.member |
| 146 | +(attribute_id) @tag |
151 | 147 |
|
152 | 148 | ; Comments |
153 | 149 | ;--------- |
154 | 150 |
|
155 | 151 | [(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