|
7 | 7 | ((value_identifier) @constant.macro
|
8 | 8 | (#match? @constant.macro "^\\.*$"))
|
9 | 9 |
|
| 10 | + |
| 11 | +((value_identifier) @variable) |
| 12 | + |
10 | 13 | [
|
11 | 14 | (type_identifier)
|
12 | 15 | (unit_type)
|
13 | 16 | (list)
|
14 | 17 | (list_pattern)
|
15 | 18 | ] @type
|
16 | 19 |
|
| 20 | +((type_identifier) @type.builtin |
| 21 | + (#any-of? @type.builtin |
| 22 | + "int" "char" "string" "float" "bool" "unit")) |
| 23 | + |
17 | 24 | [
|
18 | 25 | (variant_identifier)
|
19 | 26 | (polyvar_identifier)
|
20 |
| -] @constant |
| 27 | +] @constructor |
21 | 28 |
|
22 | 29 | (record_type_field (property_identifier) @property)
|
23 | 30 | (record_field (property_identifier) @property)
|
24 | 31 | (object (field (property_identifier) @property))
|
25 | 32 | (object_type (field (property_identifier) @property))
|
26 |
| -(member_expression (property_identifier) @property) |
27 |
| -(module_identifier) @namespace |
| 33 | +(module_identifier) @module |
| 34 | + |
| 35 | +(member_expression (property_identifier) @variable.member) |
| 36 | + |
| 37 | +(value_identifier_path |
| 38 | + (module_identifier) |
| 39 | + (value_identifier) @variable) |
| 40 | + |
| 41 | + |
| 42 | +(record_pattern |
| 43 | + (value_identifier_path |
| 44 | + (value_identifier) @variable.member)) |
| 45 | + |
| 46 | +(record_pattern |
| 47 | + (value_identifier) @variable) |
| 48 | + |
| 49 | +(labeled_argument |
| 50 | + label: (value_identifier) @variable.parameter) |
| 51 | + |
28 | 52 |
|
29 | 53 | ; Parameters
|
30 | 54 | ;----------------
|
31 | 55 |
|
32 |
| -(list_pattern (value_identifier) @parameter) |
33 |
| -(spread_pattern (value_identifier) @parameter) |
| 56 | +(list_pattern (value_identifier) @variable.parameter) |
| 57 | +(spread_pattern (value_identifier) @variable.parameter) |
34 | 58 |
|
35 | 59 | ; String literals
|
36 | 60 | ;----------------
|
|
40 | 64 | (template_string)
|
41 | 65 | ] @string
|
42 | 66 |
|
43 |
| -(template_substitution |
44 |
| - "${" @punctuation.bracket |
45 |
| - "}" @punctuation.bracket) @embedded |
46 | 67 |
|
47 |
| -(character) @string.special |
| 68 | +(character) @character |
48 | 69 | (escape_sequence) @string.escape
|
49 | 70 |
|
50 | 71 | ; Other literals
|
|
53 | 74 | [
|
54 | 75 | (true)
|
55 | 76 | (false)
|
56 |
| -] @constant.builtin |
| 77 | +] @boolean |
57 | 78 |
|
58 | 79 | (number) @number
|
59 |
| -(polyvar) @constant |
60 |
| -(polyvar_string) @constant |
| 80 | +(polyvar) @constructor |
| 81 | +(polyvar_string) @constructor |
61 | 82 |
|
62 | 83 | ; Functions
|
63 | 84 | ;----------
|
64 | 85 |
|
65 | 86 | ; parameter(s) in parens
|
66 |
| -[ |
67 |
| - (parameter (value_identifier)) |
68 |
| - (labeled_parameter (value_identifier)) |
69 |
| -] @parameter |
| 87 | + |
| 88 | +(parameter (value_identifier) @variable.parameter) |
| 89 | +(labeled_parameter (value_identifier) @variable.parameter) |
70 | 90 |
|
71 | 91 | ; single parameter with no parens
|
72 |
| -(function parameter: (value_identifier) @parameter) |
| 92 | +(function parameter: (value_identifier) @variable.parameter) |
73 | 93 |
|
74 | 94 | ; first-level descructuring (required for nvim-tree-sitter as it only matches direct
|
75 | 95 | ; children and the above patterns do not match destructuring patterns in NeoVim)
|
76 |
| -(parameter (tuple_pattern (tuple_item_pattern (value_identifier) @parameter))) |
77 |
| -(parameter (array_pattern (value_identifier) @parameter)) |
78 |
| -(parameter (record_pattern (value_identifier) @parameter)) |
| 96 | +(parameter (tuple_pattern (tuple_item_pattern (value_identifier) @variable.parameter))) |
| 97 | +(parameter (array_pattern (value_identifier) @variable.parameter)) |
| 98 | +(parameter (record_pattern (value_identifier) @variable.parameter)) |
| 99 | + |
| 100 | +; function identifier in let binding |
| 101 | +(let_binding |
| 102 | + pattern: (value_identifier) @function |
| 103 | + body: (function)) |
| 104 | + |
| 105 | +; function calls |
| 106 | + |
| 107 | +(call_expression |
| 108 | + function: (value_identifier_path |
| 109 | + _ |
| 110 | + (value_identifier) @function.call)) |
| 111 | + |
| 112 | +(call_expression |
| 113 | + function: (value_identifier) @function.call) |
| 114 | + |
| 115 | +; highlight the right-hand side of a pipe operator as a function call |
| 116 | +(pipe_expression |
| 117 | + _ |
| 118 | + [(value_identifier_path |
| 119 | + _ |
| 120 | + (value_identifier) @function.call) |
| 121 | + (value_identifier) @function.call]) |
| 122 | + |
79 | 123 |
|
80 | 124 | ; Meta
|
81 | 125 | ;-----
|
82 | 126 |
|
83 |
| -(decorator_identifier) @annotation |
| 127 | +(decorator_identifier) @attribute |
84 | 128 |
|
85 | 129 | (extension_identifier) @keyword
|
86 | 130 | ("%") @keyword
|
87 | 131 |
|
88 | 132 | ; Misc
|
89 | 133 | ;-----
|
90 | 134 |
|
91 |
| -(subscript_expression index: (string) @property) |
92 |
| -(polyvar_type_pattern "#" @constant) |
| 135 | +(polyvar_type_pattern "#" @constructor) |
93 | 136 |
|
94 | 137 | [
|
95 |
| - ("include") |
96 |
| - ("open") |
97 |
| -] @include |
| 138 | + "include" |
| 139 | + "open" |
| 140 | +] @keyword.import |
| 141 | + |
| 142 | + |
| 143 | +[ |
| 144 | + "private" |
| 145 | + "mutable" |
| 146 | + "rec" |
| 147 | +] @keyword.modifier |
| 148 | + |
| 149 | +[ |
| 150 | + "type" |
| 151 | +] @keyword.type |
98 | 152 |
|
99 | 153 | [
|
| 154 | + "and" |
| 155 | + "with" |
100 | 156 | "as"
|
| 157 | +] @keyword.operator |
| 158 | + |
| 159 | +[ |
101 | 160 | "export"
|
102 | 161 | "external"
|
103 | 162 | "let"
|
104 | 163 | "module"
|
105 |
| - "mutable" |
106 |
| - "private" |
107 |
| - "rec" |
108 |
| - "type" |
109 |
| - "and" |
110 | 164 | "assert"
|
111 | 165 | "await"
|
112 |
| - "with" |
113 | 166 | "lazy"
|
114 | 167 | "constraint"
|
115 | 168 | ] @keyword
|
116 | 169 |
|
117 |
| -((function "async" @keyword)) |
| 170 | +(("await") @keyword.coroutine) |
| 171 | + |
| 172 | +((function "async" @keyword.coroutine)) |
118 | 173 |
|
119 | 174 | (module_unpack "unpack" @keyword)
|
120 | 175 |
|
|
123 | 178 | "else"
|
124 | 179 | "switch"
|
125 | 180 | "when"
|
126 |
| -] @conditional |
| 181 | +] @keyword.conditional |
127 | 182 |
|
128 | 183 | [
|
129 | 184 | "exception"
|
130 | 185 | "try"
|
131 | 186 | "catch"
|
132 |
| -] @exception |
| 187 | +] @keyword.exception |
133 | 188 |
|
134 | 189 | (call_expression
|
135 |
| - function: (value_identifier) @exception |
136 |
| - (#eq? @exception "raise")) |
| 190 | + function: (value_identifier) @keyword.exception |
| 191 | + (#eq? @keyword.exception "raise")) |
137 | 192 |
|
138 | 193 | [
|
139 | 194 | "for"
|
140 | 195 | "in"
|
141 | 196 | "to"
|
142 | 197 | "downto"
|
143 | 198 | "while"
|
144 |
| -] @repeat |
| 199 | +] @keyword.repeat |
145 | 200 |
|
146 | 201 | [
|
147 | 202 | "."
|
148 | 203 | ","
|
149 | 204 | "|"
|
| 205 | + ":" |
150 | 206 | ] @punctuation.delimiter
|
151 | 207 |
|
152 | 208 | [
|
|
174 | 230 | "|>"
|
175 | 231 | ":>"
|
176 | 232 | "+="
|
| 233 | + "=>" |
177 | 234 | (uncurry)
|
178 | 235 | ] @operator
|
179 | 236 |
|
|
188 | 245 | "}"
|
189 | 246 | "["
|
190 | 247 | "]"
|
| 248 | + "<" |
| 249 | + ">" |
191 | 250 | ] @punctuation.bracket
|
192 | 251 |
|
| 252 | +(unit ["(" ")"] @constant.builtin) |
| 253 | + |
| 254 | +(template_substitution |
| 255 | + "${" @punctuation.special |
| 256 | + "}" @punctuation.special) @none |
| 257 | + |
193 | 258 | (polyvar_type
|
194 | 259 | [
|
195 | 260 | "["
|
|
201 | 266 | [
|
202 | 267 | "~"
|
203 | 268 | "?"
|
204 |
| - "=>" |
205 | 269 | ".."
|
206 | 270 | "..."
|
207 | 271 | ] @punctuation.special
|
208 | 272 |
|
209 |
| -(ternary_expression ["?" ":"] @operator) |
| 273 | +(ternary_expression ["?" ":"] @keyword.conditional.ternary) |
210 | 274 |
|
211 | 275 | ; JSX
|
212 | 276 | ;----------
|
|
0 commit comments