on master help sign in
highlight(scala): update the Scala highlight queries (#5546)
6f6334feugene yokota
languages.toml+1−1
@@ -1064,7 +1064,7 @@ language-server = { command = "metals" }
1064
1064
1065[[grammar]]
1065[[grammar]]
1066name = "scala"
1066name = "scala"
1067−source = { git = "https://github.com/tree-sitter/tree-sitter-scala", rev = "140c96cf398693189d4e50f76d19ddfcd8a018f8" }
1067+source = { git = "https://github.com/tree-sitter/tree-sitter-scala", rev = "db1c8c23d7996476a791db85a0d292084c19c232" }
1068
1068
1069[[language]]
1069[[language]]
1070name = "dockerfile"
1070name = "dockerfile"
runtime/queries/scala/highlights.scm+99−30
@@ -33,6 +33,26 @@
33(type_definition
33(type_definition
34 name: (type_identifier) @type)
34 name: (type_identifier) @type)
35
35
36+(full_enum_case
37+ name: (identifier) @type)
38+
39+(simple_enum_case
40+ name: (identifier) @type)
41+
42+;; val/var definitions/declarations
43+
44+(val_definition
45+ pattern: (identifier) @variable)
46+
47+(var_definition
48+ pattern: (identifier) @variable)
49+
50+(val_declaration
51+ name: (identifier) @variable)
52+
53+(var_declaration
54+ name: (identifier) @variable)
55+
36; method definition
56; method definition
37
57
38(class_definition
58(class_definition
@@ -48,7 +68,7 @@
48 (function_definition
68 (function_definition
49 name: (identifier) @function.method)))
69 name: (identifier) @function.method)))
50
70
51−; imports
71+; imports/exports
52
72
53(import_declaration
73(import_declaration
54 path: (identifier) @namespace)
74 path: (identifier) @namespace)
@@ -58,7 +78,15 @@
58 path: (identifier) @type) (#match? @type "^[A-Z]"))
78 path: (identifier) @type) (#match? @type "^[A-Z]"))
59((stable_identifier (identifier) @type) (#match? @type "^[A-Z]"))
79((stable_identifier (identifier) @type) (#match? @type "^[A-Z]"))
60
80
81+(export_declaration
82+ path: (identifier) @namespace)
83+((stable_identifier (identifier) @namespace))
84+
85+((export_declaration
86+ path: (identifier) @type) (#match? @type "^[A-Z]"))
87+((stable_identifier (identifier) @type) (#match? @type "^[A-Z]"))
88+
61−((import_selectors (identifier) @type) (#match? @type "^[A-Z]"))
89+((namespace_selectors (identifier) @type) (#match? @type "^[A-Z]"))
62
90
63; method invocation
91; method invocation
64
92
@@ -66,10 +94,17 @@
66(call_expression
94(call_expression
67 function: (identifier) @function)
95 function: (identifier) @function)
68
96
97+(call_expression
98+ function: (operator_identifier) @function)
99+
69(call_expression
100(call_expression
70 function: (field_expression
101 function: (field_expression
71 field: (identifier) @function.method))
102 field: (identifier) @function.method))
72
103
104+(call_expression
105+ function: (field_expression
106+ field: (operator_identifier) @function.method))
107+
73((call_expression
108((call_expression
74 function: (identifier) @variable.other.member)
109 function: (identifier) @variable.other.member)
75 (#match? @variable.other.member "^[A-Z]"))
110 (#match? @variable.other.member "^[A-Z]"))
@@ -87,9 +122,15 @@
87(function_definition
122(function_definition
88 name: (identifier) @function)
123 name: (identifier) @function)
89
124
125+(function_definition
126+ name: (operator_identifier) @function)
127+
90(parameter
128(parameter
91 name: (identifier) @variable.parameter)
129 name: (identifier) @variable.parameter)
92
130
131+(binding
132+ name: (identifier) @variable.parameter)
133+
93; expressions
134; expressions
94
135
95
136
@@ -109,7 +150,7 @@
109
150
110
151
111(symbol_literal) @string.special.symbol
152(symbol_literal) @string.special.symbol
112−
153+
113[
154[
114(string)
155(string)
115(character_literal)
156(character_literal)
@@ -118,29 +159,50 @@
118
159
119(interpolation "$" @punctuation.special)
160(interpolation "$" @punctuation.special)
120
161
162+; annotations
163+
164+(annotation) @attribute
165+
121;; keywords
166;; keywords
122
167
168+;; storage in TextMate scope lingo means field or type
123[
169[
170+ (opaque_modifier)
171+ (infix_modifier)
172+ (transparent_modifier)
173+ (open_modifier)
124 "abstract"
174 "abstract"
125− "case"
126− "class"
127− "extends"
128 "final"
175 "final"
129− "finally"
130−;; `forSome` existential types not implemented yet
131 "implicit"
176 "implicit"
132 "lazy"
177 "lazy"
133−;; `macro` not implemented yet
134− "object"
135 "override"
178 "override"
136− "package"
137 "private"
179 "private"
138 "protected"
180 "protected"
139 "sealed"
181 "sealed"
182+] @keyword.storage.modifier
183+
184+[
185+ "class"
186+ "enum"
187+ "extension"
188+ "given"
189+ "object"
190+ "package"
140 "trait"
191 "trait"
141 "type"
192 "type"
142 "val"
193 "val"
143 "var"
194 "var"
195+] @keyword.storage.type
196+
197+[
198+ "as"
199+ "derives"
200+ "end"
201+ "extends"
202+;; `forSome` existential types not implemented yet
203+;; `macro` not implemented yet
204+;; `throws`
205+ "using"
144 "with"
206 "with"
145] @keyword
207] @keyword
146
208
@@ -152,33 +214,36 @@
152"new" @keyword.operator
214"new" @keyword.operator
153
215
154[
216[
217+ "case"
218+ "catch"
155− "else"
219+ "else"
220+ "finally"
156− "if"
221+ "if"
157− "match"
222+ "match"
158− "try"
223+ "then"
159− "catch"
160− "throw"
224+ "throw"
225+ "try"
161] @keyword.control.conditional
226] @keyword.control.conditional
162
227
163[
228[
164− "("
229+ "("
165− ")"
230+ ")"
166− "["
231+ "["
167− "]"
232+ "]"
168− "{"
233+ "{"
169− "}"
234+ "}"
170] @punctuation.bracket
235] @punctuation.bracket
171
236
172[
237[
173− "."
238+ "."
174− ","
239+ ","
175] @punctuation.delimiter
240] @punctuation.delimiter
176
241
177[
242[
178− "do"
243+ "do"
179− "for"
244+ "for"
180− "while"
245+ "while"
181− "yield"
246+ "yield"
182] @keyword.control.repeat
247] @keyword.control.repeat
183
248
184"def" @keyword.function
249"def" @keyword.function
@@ -191,6 +256,8 @@
191
256
192"import" @keyword.control.import
257"import" @keyword.control.import
193
258
259+"export" @keyword.control.import
260+
194"return" @keyword.control.return
261"return" @keyword.control.return
195
262
196(comment) @comment
263(comment) @comment
@@ -200,4 +267,6 @@
200(case_block
267(case_block
201 (case_clause ("case") @keyword.control.conditional))
268 (case_clause ("case") @keyword.control.conditional))
202
269
203−(identifier) @variable
270+(identifier) @variable
271+
272+(operator_identifier) @operator