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