Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/swift/highlights.scm')
-rw-r--r--runtime/queries/swift/highlights.scm172
1 files changed, 65 insertions, 107 deletions
diff --git a/runtime/queries/swift/highlights.scm b/runtime/queries/swift/highlights.scm
index ecafde40..fe240e9d 100644
--- a/runtime/queries/swift/highlights.scm
+++ b/runtime/queries/swift/highlights.scm
@@ -1,57 +1,10 @@
-; Upstream: https://github.com/alex-pinkus/tree-sitter-swift/blob/57c1c6d6ffa1c44b330182d41717e6fe37430704/queries/highlights.scm
-
-(line_string_literal
- ["\\(" ")"] @punctuation.special)
-
-["." ";" ":" "," ] @punctuation.delimiter
-["(" ")" "[" "]" "{" "}" "<" ">"] @punctuation.bracket
-
-; Operators
-[
- "!"
- "?"
- "+"
- "-"
- "\\"
- "*"
- "/"
- "%"
- "="
- "+="
- "-="
- "*="
- "/="
- "<"
- ">"
- "<="
- ">="
- "++"
- "--"
- "&"
- "~"
- "%="
- "!="
- "!=="
- "=="
- "==="
- "??"
-
- "->"
-
- "..<"
- "..."
- (custom_operator)
-] @operator
-
-"?" @type
-(type_annotation "!" @type)
+[ "." ";" ":" "," ] @punctuation.delimiter
+[ "\\(" "(" ")" "[" "]" "{" "}"] @punctuation.bracket ; TODO: "\\(" ")" in interpolations should be @punctuation.special
; Identifiers
-(simple_identifier) @variable
(attribute) @variable
(type_identifier) @type
(self_expression) @variable.builtin
-(user_type (type_identifier) @variable.builtin (#eq? @variable.builtin "Self"))
; Declarations
"func" @keyword.function
@@ -65,63 +18,40 @@
] @keyword
(function_declaration (simple_identifier) @function.method)
-(protocol_function_declaration (simple_identifier) @function.method)
-(init_declaration ["init" @constructor])
-(deinit_declaration ["deinit" @constructor])
-
+(function_declaration ["init" @constructor])
(throws) @keyword
"async" @keyword
-"await" @keyword
(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))
-(pattern bound_identifier: (simple_identifier)) @variable
+(non_binding_pattern bound_identifier: (simple_identifier)) @variable
[
"typealias"
"struct"
"class"
- "actor"
"enum"
"protocol"
"extension"
"indirect"
- "nonisolated"
- "override"
- "convenience"
- "required"
- "mutating"
- "associatedtype"
- "package"
- "any"
+ "some"
] @keyword
-(opaque_type ["some" @keyword])
-(existential_type ["any" @keyword])
-
-(precedence_group_declaration
- ["precedencegroup" @keyword]
- (simple_identifier) @type)
-(precedence_group_attribute
- (simple_identifier) @keyword
- [(simple_identifier) @type
- (boolean_literal) @constant.builtin.boolean])
-
[
(getter_specifier)
(setter_specifier)
(modify_specifier)
] @keyword
-(class_body (property_declaration (pattern (simple_identifier) @variable.other.member)))
-(protocol_property_declaration (pattern (simple_identifier) @variable.other.member))
+(class_body (property_declaration (value_binding_pattern (non_binding_pattern (simple_identifier) @variable.other.member))))
+(protocol_property_declaration (value_binding_pattern (non_binding_pattern (simple_identifier) @variable.other.member)))
-(import_declaration "import" @keyword.control.import)
+(import_declaration ["import" @keyword.control.import])
-(enum_entry "case" @keyword)
+(enum_entry ["case" @keyword])
; Function calls
(call_expression (simple_identifier) @function) ; foo()
@@ -131,20 +61,13 @@
((navigation_expression
(simple_identifier) @type) ; SomeType.method(): highlight SomeType as a type
(#match? @type "^[A-Z]"))
-(call_expression (simple_identifier) @keyword (#eq? @keyword "defer")) ; defer { ... }
-
-(navigation_suffix
- (simple_identifier) @variable.other.member)
-
-(try_operator) @operator
-(try_operator ["try" @keyword])
(directive) @function.macro
(diagnostic) @function.macro
; Statements
-(for_statement "for" @keyword.control.repeat)
-(for_statement "in" @keyword.control.repeat)
+(for_statement ["for" @keyword.control.repeat])
+(for_statement ["in" @keyword.control.repeat])
(for_statement item: (simple_identifier) @variable)
(else) @keyword
(as_operator) @keyword
@@ -152,14 +75,15 @@
["while" "repeat" "continue" "break"] @keyword.control.repeat
["let" "var"] @keyword
+(non_binding_pattern (simple_identifier) @variable)
-(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)
+(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])
(switch_entry (default_keyword) @keyword)
-"return" @keyword.return
+"return" @keyword.control.return
(ternary_expression
["?" ":"] @keyword.control.conditional)
@@ -168,8 +92,8 @@
(statement_label) @label
; Comments
-(comment) @comment
-(multiline_comment) @comment
+(comment) @comment.line
+(multiline_comment) @comment.block
; String literals
(line_str_text) @string
@@ -177,24 +101,58 @@
(multi_line_str_text) @string
(raw_str_part) @string
(raw_str_end_part) @string
-(raw_str_interpolation_start) @punctuation.special
+(raw_str_interpolation_start) @string.special
["\"" "\"\"\""] @string
; Lambda literals
-(lambda_literal "in" @keyword.operator)
+(lambda_literal ["in" @keyword.operator])
; Basic literals
+(integer_literal) @constant.numeric.integer
[
- (hex_literal)
- (oct_literal)
- (bin_literal)
+ (hex_literal)
+ (oct_literal)
+ (bin_literal)
] @constant.numeric
-(integer_literal) @constant.numeric.integer
(real_literal) @constant.numeric.float
(boolean_literal) @constant.builtin.boolean
-"nil" @constant.builtin
+"nil" @variable.builtin
+
+; Operators
+(custom_operator) @operator
+[
+ "try"
+ "try?"
+ "try!"
+ "!"
+ "+"
+ "-"
+ "*"
+ "/"
+ "%"
+ "="
+ "+="
+ "-="
+ "*="
+ "/="
+ "<"
+ ">"
+ "<="
+ ">="
+ "++"
+ "--"
+ "&"
+ "~"
+ "%="
+ "!="
+ "!=="
+ "=="
+ "==="
+ "??"
+
+ "->"
+
+ "..<"
+ "..."
+] @operator
-(value_parameter_pack ["each" @keyword])
-(value_pack_expansion ["repeat" @keyword])
-(type_parameter_pack ["each" @keyword])
-(type_pack_expansion ["repeat" @keyword])