2024-02-12 02:17:44 +01:00
|
|
|
; Upstream: https://github.com/alex-pinkus/tree-sitter-swift/blob/1c586339fb00014b23d6933f2cc32b588a226f3b/queries/highlights.scm
|
2022-08-17 03:40:21 +02:00
|
|
|
|
|
|
|
(line_string_literal
|
|
|
|
["\\(" ")"] @punctuation.special)
|
|
|
|
|
|
|
|
["." ";" ":" "," ] @punctuation.delimiter
|
2024-02-12 02:17:44 +01:00
|
|
|
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
|
2022-04-08 20:10:37 +02:00
|
|
|
|
|
|
|
; Identifiers
|
|
|
|
(attribute) @variable
|
|
|
|
(type_identifier) @type
|
|
|
|
(self_expression) @variable.builtin
|
|
|
|
|
|
|
|
; Declarations
|
|
|
|
"func" @keyword.function
|
|
|
|
[
|
|
|
|
(visibility_modifier)
|
|
|
|
(member_modifier)
|
|
|
|
(function_modifier)
|
|
|
|
(property_modifier)
|
|
|
|
(parameter_modifier)
|
|
|
|
(inheritance_modifier)
|
|
|
|
] @keyword
|
|
|
|
|
|
|
|
(function_declaration (simple_identifier) @function.method)
|
2022-08-17 03:40:21 +02:00
|
|
|
(function_declaration "init" @constructor)
|
2022-04-08 20:10:37 +02:00
|
|
|
(throws) @keyword
|
|
|
|
"async" @keyword
|
2024-02-12 02:17:44 +01:00
|
|
|
"await" @keyword
|
2022-04-08 20:10:37 +02:00
|
|
|
(where_keyword) @keyword
|
|
|
|
(parameter external_name: (simple_identifier) @variable.parameter)
|
|
|
|
(parameter name: (simple_identifier) @variable.parameter)
|
|
|
|
(type_parameter (type_identifier) @variable.parameter)
|
|
|
|
(inheritance_constraint (identifier (simple_identifier) @variable.parameter))
|
|
|
|
(equality_constraint (identifier (simple_identifier) @variable.parameter))
|
2022-08-17 03:40:21 +02:00
|
|
|
(pattern bound_identifier: (simple_identifier)) @variable
|
2022-04-08 20:10:37 +02:00
|
|
|
|
|
|
|
[
|
|
|
|
"typealias"
|
|
|
|
"struct"
|
|
|
|
"class"
|
2022-08-17 03:40:21 +02:00
|
|
|
"actor"
|
2022-04-08 20:10:37 +02:00
|
|
|
"enum"
|
|
|
|
"protocol"
|
|
|
|
"extension"
|
|
|
|
"indirect"
|
2022-08-17 03:40:21 +02:00
|
|
|
"nonisolated"
|
|
|
|
"override"
|
|
|
|
"convenience"
|
|
|
|
"required"
|
2022-04-08 20:10:37 +02:00
|
|
|
"some"
|
2024-02-12 02:17:44 +01:00
|
|
|
"any"
|
2022-04-08 20:10:37 +02:00
|
|
|
] @keyword
|
|
|
|
|
|
|
|
[
|
|
|
|
(getter_specifier)
|
|
|
|
(setter_specifier)
|
|
|
|
(modify_specifier)
|
|
|
|
] @keyword
|
|
|
|
|
2022-08-17 03:40:21 +02:00
|
|
|
(class_body (property_declaration (pattern (simple_identifier) @variable.other.member)))
|
|
|
|
(protocol_property_declaration (pattern (simple_identifier) @variable.other.member))
|
2022-04-08 20:10:37 +02:00
|
|
|
|
2022-08-17 03:40:21 +02:00
|
|
|
(import_declaration "import" @keyword.control.import)
|
2022-04-08 20:10:37 +02:00
|
|
|
|
2022-08-17 03:40:21 +02:00
|
|
|
(enum_entry "case" @keyword)
|
2022-04-08 20:10:37 +02:00
|
|
|
|
|
|
|
; Function calls
|
|
|
|
(call_expression (simple_identifier) @function) ; foo()
|
|
|
|
(call_expression ; foo.bar.baz(): highlight the baz()
|
|
|
|
(navigation_expression
|
|
|
|
(navigation_suffix (simple_identifier) @function)))
|
|
|
|
((navigation_expression
|
|
|
|
(simple_identifier) @type) ; SomeType.method(): highlight SomeType as a type
|
|
|
|
(#match? @type "^[A-Z]"))
|
|
|
|
|
|
|
|
(directive) @function.macro
|
|
|
|
(diagnostic) @function.macro
|
|
|
|
|
|
|
|
; Statements
|
2022-08-17 03:40:21 +02:00
|
|
|
(for_statement "for" @keyword.control.repeat)
|
|
|
|
(for_statement "in" @keyword.control.repeat)
|
2022-04-08 20:10:37 +02:00
|
|
|
(for_statement item: (simple_identifier) @variable)
|
|
|
|
(else) @keyword
|
|
|
|
(as_operator) @keyword
|
|
|
|
|
|
|
|
["while" "repeat" "continue" "break"] @keyword.control.repeat
|
|
|
|
|
|
|
|
["let" "var"] @keyword
|
|
|
|
|
2022-08-17 03:40:21 +02:00
|
|
|
(guard_statement "guard" @keyword.control.conditional)
|
|
|
|
(if_statement "if" @keyword.control.conditional)
|
|
|
|
(switch_statement "switch" @keyword.control.conditional)
|
|
|
|
(switch_entry "case" @keyword)
|
|
|
|
(switch_entry "fallthrough" @keyword)
|
2022-04-08 20:10:37 +02:00
|
|
|
(switch_entry (default_keyword) @keyword)
|
2022-08-17 03:40:21 +02:00
|
|
|
"return" @keyword.return
|
2022-04-08 20:10:37 +02:00
|
|
|
(ternary_expression
|
|
|
|
["?" ":"] @keyword.control.conditional)
|
|
|
|
|
|
|
|
["do" (throw_keyword) (catch_keyword)] @keyword
|
|
|
|
|
|
|
|
(statement_label) @label
|
|
|
|
|
|
|
|
; Comments
|
2022-08-17 03:40:21 +02:00
|
|
|
(comment) @comment
|
|
|
|
(multiline_comment) @comment
|
2022-04-08 20:10:37 +02:00
|
|
|
|
|
|
|
; String literals
|
|
|
|
(line_str_text) @string
|
|
|
|
(str_escaped_char) @string
|
|
|
|
(multi_line_str_text) @string
|
|
|
|
(raw_str_part) @string
|
|
|
|
(raw_str_end_part) @string
|
2022-08-17 03:40:21 +02:00
|
|
|
(raw_str_interpolation_start) @punctuation.special
|
2022-04-08 20:10:37 +02:00
|
|
|
["\"" "\"\"\""] @string
|
|
|
|
|
|
|
|
; Lambda literals
|
2022-08-17 03:40:21 +02:00
|
|
|
(lambda_literal "in" @keyword.operator)
|
2022-04-08 20:10:37 +02:00
|
|
|
|
|
|
|
; Basic literals
|
|
|
|
[
|
2022-08-17 03:40:21 +02:00
|
|
|
(hex_literal)
|
|
|
|
(oct_literal)
|
|
|
|
(bin_literal)
|
2022-04-08 20:10:37 +02:00
|
|
|
] @constant.numeric
|
2022-08-17 03:40:21 +02:00
|
|
|
(integer_literal) @constant.numeric.integer
|
2022-04-08 20:10:37 +02:00
|
|
|
(real_literal) @constant.numeric.float
|
|
|
|
(boolean_literal) @constant.builtin.boolean
|
|
|
|
"nil" @variable.builtin
|
|
|
|
|
2022-08-17 03:40:21 +02:00
|
|
|
"?" @type
|
|
|
|
(type_annotation "!" @type)
|
|
|
|
|
|
|
|
(simple_identifier) @variable
|
|
|
|
|
2022-04-08 20:10:37 +02:00
|
|
|
; Operators
|
|
|
|
[
|
2022-08-17 03:40:21 +02:00
|
|
|
"try"
|
|
|
|
"try?"
|
|
|
|
"try!"
|
|
|
|
"!"
|
|
|
|
"+"
|
|
|
|
"-"
|
|
|
|
"*"
|
|
|
|
"/"
|
|
|
|
"%"
|
|
|
|
"="
|
|
|
|
"+="
|
|
|
|
"-="
|
|
|
|
"*="
|
|
|
|
"/="
|
|
|
|
"<"
|
|
|
|
">"
|
|
|
|
"<="
|
|
|
|
">="
|
|
|
|
"++"
|
|
|
|
"--"
|
|
|
|
"&"
|
|
|
|
"~"
|
|
|
|
"%="
|
|
|
|
"!="
|
|
|
|
"!=="
|
|
|
|
"=="
|
|
|
|
"==="
|
|
|
|
"??"
|
|
|
|
|
|
|
|
"->"
|
|
|
|
|
|
|
|
"..<"
|
|
|
|
"..."
|
|
|
|
(custom_operator)
|
2022-04-08 20:10:37 +02:00
|
|
|
] @operator
|