@@ -0,0 +1,295 @@
1+;;; Operators & Punctuation
3+(multi_line_string_literal
5+ (interpolated_identifier) @none)
6+(multi_line_string_literal
8+ (interpolated_expression) @none
11+; NOTE: `interpolated_identifier`s can be highlighted in any way
14+ (interpolated_identifier) @none)
17+ (interpolated_expression) @none
26+] @punctuation.delimiter
32+] @punctuation.bracket
74+(type_alias "typealias" @keyword)
83+ (visibility_modifier)
84+ (reification_modifier)
85+ (inheritance_modifier)
95+; "typeof" ; NOTE: It is reserved for future use
98+("fun") @keyword.function
100+(jump_expression) @keyword.control.return
106+] @keyword.control.conditional
112+] @keyword.control.repeat
119+] @keyword.control.exception
122+ "@" @attribute (use_site_target)? @attribute)
125+ (type_identifier) @attribute))
127+ (constructor_invocation
129+ (type_identifier) @attribute)))
132+ "@" @attribute "file" @attribute ":" @attribute)
135+ (type_identifier) @attribute))
137+ (constructor_invocation
139+ (type_identifier) @attribute)))
142+; NOTE: Escapes not allowed in multi-line strings
143+(line_string_literal (character_escape_seq) @constant.character.escape)
146+ (line_string_literal)
147+ (multi_line_string_literal)
150+(character_literal) @constant.character
153+ "null" ; should be highlighted the same as booleans
155+] @constant.builtin.boolean
157+(real_literal) @constant.numeric.float
164+] @constant.numeric.integer
174+ . (simple_identifier) @function.builtin
175+ (#match? @function.builtin "^(arrayOf|arrayOfNulls|byteArrayOf|shortArrayOf|intArrayOf|longArrayOf|ubyteArrayOf|ushortArrayOf|uintArrayOf|ulongArrayOf|floatArrayOf|doubleArrayOf|booleanArrayOf|charArrayOf|emptyArray|mapOf|setOf|listOf|emptyMap|emptySet|emptyList|mutableMapOf|mutableSetOf|mutableListOf|print|println|error|TODO|run|runCatching|repeat|lazy|lazyOf|enumValues|enumValueOf|assert|check|checkNotNull|require|requireNotNull|with|suspend|synchronized)$"))
177+; object.function() or object.property.function()
179+ (navigation_expression
181+ (simple_identifier) @function) . ))
185+ . (simple_identifier) @function)
187+;;; Function definitions
192+ (variable_declaration
193+ (simple_identifier) @variable.parameter)))
195+(parameter_with_optional_type
196+ (simple_identifier) @variable.parameter)
199+ (simple_identifier) @variable.parameter)
201+(anonymous_initializer
202+ ("init") @constructor)
204+(constructor_invocation
206+ (type_identifier) @constructor))
208+(secondary_constructor
209+ ("constructor") @constructor)
210+(primary_constructor) @constructor
213+ ("get") @function.builtin)
215+ ("set") @function.builtin)
217+(function_declaration
218+ . (simple_identifier) @function)
220+; TODO: Seperate labeled returns/breaks/continue/super/this
221+; Must be implemented in the parser first
226+ (simple_identifier) @function @_import .)
228+ (type_identifier) @function)?
229+ (#match? @_import "^[a-z]"))
231+; The last `simple_identifier` in a `import_header` will always either be a function
232+; or a type. Classes can appear anywhere in the import path, unlike functions
235+ (simple_identifier) @type @_import)
237+ (type_identifier) @type)?
238+ (#match? @_import "^[A-Z]"))
241+ "import" @keyword.control.import)
244+ . (identifier)) @namespace
246+((type_identifier) @type.builtin
247+ (#match? @function.builtin "^(Byte|Short|Int|Long|UByte|UShort|UInt|ULong|Float|Double|Boolean|Char|String|Array|ByteArray|ShortArray|IntArray|LongArray|UByteArray|UShortArray|UIntArray|ULongArray|FloatArray|DoubleArray|BooleanArray|CharArray|Map|Set|List|EmptyMap|EmptySet|EmptyList|MutableMap|MutableSet|MutableList)$"))
249+(type_identifier) @type
252+ (simple_identifier) @constant)
256+ (simple_identifier) @constant
257+ (#match? @constant "^[A-Z][A-Z0-9_]*$")))
259+; SCREAMING CASE identifiers are assumed to be constants
260+((simple_identifier) @constant
261+(#match? @constant "^[A-Z][A-Z0-9_]*$"))
263+; id_1.id_2.id_3: `id_2` and `id_3` are assumed as object properties
266+ (simple_identifier) @variable.other.member))
269+ (property_declaration
270+ (variable_declaration
271+ (simple_identifier) @variable.other.member)))
274+ (simple_identifier) @variable.other.member)
276+; `super` keyword inside classes
277+(super_expression) @variable.builtin
279+; `this` this keyword inside classes
280+(this_expression) @variable.builtin
283+; `field` keyword inside property getter/setter
284+; FIXME: This will highlight the keyword outside of getters and setters
285+; since tree-sitter does not allow us to check for arbitrary nestation
286+((simple_identifier) @variable.builtin
287+(#eq? @variable.builtin "field"))
289+; `it` keyword inside lambdas
290+; FIXME: This will highlight the keyword outside of lambdas since tree-sitter
291+; does not allow us to check for arbitrary nestation
292+((simple_identifier) @variable.builtin
293+(#eq? @variable.builtin "it"))
295+(simple_identifier) @variable