Skip to content

Commit 7dd646f

Browse files
committed
Refactor highlighting
tree-sitter now uses last-wins rules for highlighting. This moves the rules around to match the older highlighting. Except operator, which I've now let it take precedence over `function.call`.
1 parent fb4e246 commit 7dd646f

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

queries/scala/highlights.scm

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
; CREDITS @stumash ([email protected])
22

3+
(field_expression field: (identifier) @property)
4+
(field_expression value: (identifier) @type
5+
(#match? @type "^[A-Z]"))
6+
7+
(type_identifier) @type
8+
39
(class_definition
410
name: (identifier) @type)
511

@@ -20,7 +26,7 @@
2026

2127
;; variables
2228

23-
(class_parameter
29+
(class_parameter
2430
name: (identifier) @parameter)
2531

2632
(self_type (identifier) @parameter)
@@ -33,8 +39,6 @@
3339
(type_definition
3440
name: (type_identifier) @type.definition)
3541

36-
(type_identifier) @type
37-
3842
;; val/var definitions/declarations
3943

4044
(val_definition
@@ -49,14 +53,6 @@
4953
(var_declaration
5054
name: (identifier) @variable)
5155

52-
; method definition
53-
54-
(function_declaration
55-
name: (identifier) @method)
56-
57-
(function_definition
58-
name: (identifier) @method)
59-
6056
; imports/exports
6157

6258
(import_declaration
@@ -110,11 +106,15 @@
110106
(binding
111107
name: (identifier) @parameter)
112108

113-
; expressions
109+
; method definition
114110

115-
(field_expression field: (identifier) @property)
116-
(field_expression value: (identifier) @type
117-
(#match? @type "^[A-Z]"))
111+
(function_declaration
112+
name: (identifier) @method)
113+
114+
(function_definition
115+
name: (identifier) @method)
116+
117+
; expressions
118118

119119
(infix_expression operator: (identifier) @operator)
120120
(infix_expression operator: (operator_identifier) @operator)
@@ -235,8 +235,8 @@
235235

236236
"return" @keyword.return
237237

238-
(comment) @comment @spell
239-
(block_comment) @comment @spell
238+
(comment) @spell @comment
239+
(block_comment) @spell @comment
240240

241241
;; `case` is a conditional keyword in case_block
242242

test/highlight/scala3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ object A:
117117
// ^type
118118

119119
::(123)
120-
//^function.call
120+
//^operator
121121
// ^number
122122

123123
object bla:

0 commit comments

Comments
 (0)