|
1 |
| -[ "." ";" ":" "," ] @punctuation.delimiter |
2 |
| -[ "\\(" "(" ")" "[" "]" "{" "}"] @punctuation.bracket ; TODO: "\\(" ")" in interpolations should be @punctuation.special |
| 1 | +; Upstream: https://github.com/alex-pinkus/tree-sitter-swift/blob/8d2fd80e3322df51e3f70952e60d57f5d4077eb8/queries/highlights.scm |
| 2 | + |
| 3 | +(line_string_literal |
| 4 | + ["\\(" ")"] @punctuation.special) |
| 5 | + |
| 6 | +["." ";" ":" "," ] @punctuation.delimiter |
| 7 | +["(" ")" "[" "]" "{" "}"] @punctuation.bracket ; TODO: "\\(" ")" in interpolations should be @punctuation.special |
3 | 8 |
|
4 | 9 | ; Identifiers
|
5 | 10 | (attribute) @variable
|
|
18 | 23 | ] @keyword
|
19 | 24 |
|
20 | 25 | (function_declaration (simple_identifier) @function.method)
|
21 |
| -(function_declaration ["init" @constructor]) |
| 26 | +(function_declaration "init" @constructor) |
22 | 27 | (throws) @keyword
|
23 | 28 | "async" @keyword
|
24 | 29 | (where_keyword) @keyword
|
|
27 | 32 | (type_parameter (type_identifier) @variable.parameter)
|
28 | 33 | (inheritance_constraint (identifier (simple_identifier) @variable.parameter))
|
29 | 34 | (equality_constraint (identifier (simple_identifier) @variable.parameter))
|
30 |
| -(non_binding_pattern bound_identifier: (simple_identifier)) @variable |
| 35 | +(pattern bound_identifier: (simple_identifier)) @variable |
31 | 36 |
|
32 | 37 | [
|
33 | 38 | "typealias"
|
34 | 39 | "struct"
|
35 | 40 | "class"
|
| 41 | + "actor" |
36 | 42 | "enum"
|
37 | 43 | "protocol"
|
38 | 44 | "extension"
|
39 | 45 | "indirect"
|
| 46 | + "nonisolated" |
| 47 | + "override" |
| 48 | + "convenience" |
| 49 | + "required" |
40 | 50 | "some"
|
41 | 51 | ] @keyword
|
42 | 52 |
|
|
46 | 56 | (modify_specifier)
|
47 | 57 | ] @keyword
|
48 | 58 |
|
49 |
| -(class_body (property_declaration (value_binding_pattern (non_binding_pattern (simple_identifier) @variable.other.member)))) |
50 |
| -(protocol_property_declaration (value_binding_pattern (non_binding_pattern (simple_identifier) @variable.other.member))) |
| 59 | +(class_body (property_declaration (pattern (simple_identifier) @variable.other.member))) |
| 60 | +(protocol_property_declaration (pattern (simple_identifier) @variable.other.member)) |
51 | 61 |
|
52 |
| -(import_declaration ["import" @keyword.control.import]) |
| 62 | +(import_declaration "import" @keyword.control.import) |
53 | 63 |
|
54 |
| -(enum_entry ["case" @keyword]) |
| 64 | +(enum_entry "case" @keyword) |
55 | 65 |
|
56 | 66 | ; Function calls
|
57 | 67 | (call_expression (simple_identifier) @function) ; foo()
|
|
66 | 76 | (diagnostic) @function.macro
|
67 | 77 |
|
68 | 78 | ; Statements
|
69 |
| -(for_statement ["for" @keyword.control.repeat]) |
70 |
| -(for_statement ["in" @keyword.control.repeat]) |
| 79 | +(for_statement "for" @keyword.control.repeat) |
| 80 | +(for_statement "in" @keyword.control.repeat) |
71 | 81 | (for_statement item: (simple_identifier) @variable)
|
72 | 82 | (else) @keyword
|
73 | 83 | (as_operator) @keyword
|
74 | 84 |
|
75 | 85 | ["while" "repeat" "continue" "break"] @keyword.control.repeat
|
76 | 86 |
|
77 | 87 | ["let" "var"] @keyword
|
78 |
| -(non_binding_pattern (simple_identifier) @variable) |
79 | 88 |
|
80 |
| -(guard_statement ["guard" @keyword.control.conditional]) |
81 |
| -(if_statement ["if" @keyword.control.conditional]) |
82 |
| -(switch_statement ["switch" @keyword.control.conditional]) |
83 |
| -(switch_entry ["case" @keyword]) |
84 |
| -(switch_entry ["fallthrough" @keyword]) |
| 89 | +(guard_statement "guard" @keyword.control.conditional) |
| 90 | +(if_statement "if" @keyword.control.conditional) |
| 91 | +(switch_statement "switch" @keyword.control.conditional) |
| 92 | +(switch_entry "case" @keyword) |
| 93 | +(switch_entry "fallthrough" @keyword) |
85 | 94 | (switch_entry (default_keyword) @keyword)
|
86 |
| -"return" @keyword.control.return |
| 95 | +"return" @keyword.return |
87 | 96 | (ternary_expression
|
88 | 97 | ["?" ":"] @keyword.control.conditional)
|
89 | 98 |
|
|
92 | 101 | (statement_label) @label
|
93 | 102 |
|
94 | 103 | ; Comments
|
95 |
| -(comment) @comment.line |
96 |
| -(multiline_comment) @comment.block |
| 104 | +(comment) @comment |
| 105 | +(multiline_comment) @comment |
97 | 106 |
|
98 | 107 | ; String literals
|
99 | 108 | (line_str_text) @string
|
100 | 109 | (str_escaped_char) @string
|
101 | 110 | (multi_line_str_text) @string
|
102 | 111 | (raw_str_part) @string
|
103 | 112 | (raw_str_end_part) @string
|
104 |
| -(raw_str_interpolation_start) @string.special |
| 113 | +(raw_str_interpolation_start) @punctuation.special |
105 | 114 | ["\"" "\"\"\""] @string
|
106 | 115 |
|
107 | 116 | ; Lambda literals
|
108 |
| -(lambda_literal ["in" @keyword.operator]) |
| 117 | +(lambda_literal "in" @keyword.operator) |
109 | 118 |
|
110 | 119 | ; Basic literals
|
111 |
| -(integer_literal) @constant.numeric.integer |
112 | 120 | [
|
113 |
| - (hex_literal) |
114 |
| - (oct_literal) |
115 |
| - (bin_literal) |
| 121 | + (hex_literal) |
| 122 | + (oct_literal) |
| 123 | + (bin_literal) |
116 | 124 | ] @constant.numeric
|
| 125 | +(integer_literal) @constant.numeric.integer |
117 | 126 | (real_literal) @constant.numeric.float
|
118 | 127 | (boolean_literal) @constant.builtin.boolean
|
119 | 128 | "nil" @variable.builtin
|
120 | 129 |
|
| 130 | +"?" @type |
| 131 | +(type_annotation "!" @type) |
| 132 | + |
| 133 | +(simple_identifier) @variable |
| 134 | + |
121 | 135 | ; Operators
|
122 |
| -(custom_operator) @operator |
123 | 136 | [
|
124 |
| - "try" |
125 |
| - "try?" |
126 |
| - "try!" |
127 |
| - "!" |
128 |
| - "+" |
129 |
| - "-" |
130 |
| - "*" |
131 |
| - "/" |
132 |
| - "%" |
133 |
| - "=" |
134 |
| - "+=" |
135 |
| - "-=" |
136 |
| - "*=" |
137 |
| - "/=" |
138 |
| - "<" |
139 |
| - ">" |
140 |
| - "<=" |
141 |
| - ">=" |
142 |
| - "++" |
143 |
| - "--" |
144 |
| - "&" |
145 |
| - "~" |
146 |
| - "%=" |
147 |
| - "!=" |
148 |
| - "!==" |
149 |
| - "==" |
150 |
| - "===" |
151 |
| - "??" |
152 |
| - |
153 |
| - "->" |
154 |
| - |
155 |
| - "..<" |
156 |
| - "..." |
| 137 | + "try" |
| 138 | + "try?" |
| 139 | + "try!" |
| 140 | + "!" |
| 141 | + "+" |
| 142 | + "-" |
| 143 | + "*" |
| 144 | + "/" |
| 145 | + "%" |
| 146 | + "=" |
| 147 | + "+=" |
| 148 | + "-=" |
| 149 | + "*=" |
| 150 | + "/=" |
| 151 | + "<" |
| 152 | + ">" |
| 153 | + "<=" |
| 154 | + ">=" |
| 155 | + "++" |
| 156 | + "--" |
| 157 | + "&" |
| 158 | + "~" |
| 159 | + "%=" |
| 160 | + "!=" |
| 161 | + "!==" |
| 162 | + "==" |
| 163 | + "===" |
| 164 | + "??" |
| 165 | + |
| 166 | + "->" |
| 167 | + |
| 168 | + "..<" |
| 169 | + "..." |
| 170 | + (custom_operator) |
157 | 171 | ] @operator
|
158 |
| - |
|
0 commit comments