From 7dd646ff64bc5eb2286ca85b9d04ecbc4e919697 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 11 Mar 2024 10:22:30 -0400 Subject: [PATCH] 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`. --- queries/scala/highlights.scm | 34 +++++++++++++++++----------------- test/highlight/scala3.scala | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/queries/scala/highlights.scm b/queries/scala/highlights.scm index ed20b2740..7f26e1bfc 100644 --- a/queries/scala/highlights.scm +++ b/queries/scala/highlights.scm @@ -1,5 +1,11 @@ ; CREDITS @stumash (stuart.mashaal@gmail.com) +(field_expression field: (identifier) @property) +(field_expression value: (identifier) @type + (#match? @type "^[A-Z]")) + +(type_identifier) @type + (class_definition name: (identifier) @type) @@ -20,7 +26,7 @@ ;; variables -(class_parameter +(class_parameter name: (identifier) @parameter) (self_type (identifier) @parameter) @@ -33,8 +39,6 @@ (type_definition name: (type_identifier) @type.definition) -(type_identifier) @type - ;; val/var definitions/declarations (val_definition @@ -49,14 +53,6 @@ (var_declaration name: (identifier) @variable) -; method definition - -(function_declaration - name: (identifier) @method) - -(function_definition - name: (identifier) @method) - ; imports/exports (import_declaration @@ -110,11 +106,15 @@ (binding name: (identifier) @parameter) -; expressions +; method definition -(field_expression field: (identifier) @property) -(field_expression value: (identifier) @type - (#match? @type "^[A-Z]")) +(function_declaration + name: (identifier) @method) + +(function_definition + name: (identifier) @method) + +; expressions (infix_expression operator: (identifier) @operator) (infix_expression operator: (operator_identifier) @operator) @@ -235,8 +235,8 @@ "return" @keyword.return -(comment) @comment @spell -(block_comment) @comment @spell +(comment) @spell @comment +(block_comment) @spell @comment ;; `case` is a conditional keyword in case_block diff --git a/test/highlight/scala3.scala b/test/highlight/scala3.scala index f55d241cd..979ecfd03 100644 --- a/test/highlight/scala3.scala +++ b/test/highlight/scala3.scala @@ -117,7 +117,7 @@ object A: // ^type ::(123) -//^function.call +//^operator // ^number object bla: