From a2b23ad7c39076dd5aab1e77447f0e2c3e7d1079 Mon Sep 17 00:00:00 2001 From: rochala Date: Mon, 11 Mar 2024 14:59:26 +0100 Subject: [PATCH] Sync with nvim-treesitter 77e2898e --- queries/scala/highlights.scm | 196 +++++++++++++++++++++-------------- 1 file changed, 116 insertions(+), 80 deletions(-) diff --git a/queries/scala/highlights.scm b/queries/scala/highlights.scm index ed20b274..99e8d354 100644 --- a/queries/scala/highlights.scm +++ b/queries/scala/highlights.scm @@ -1,5 +1,4 @@ ; CREDITS @stumash (stuart.mashaal@gmail.com) - (class_definition name: (identifier) @type) @@ -18,25 +17,26 @@ (simple_enum_case name: (identifier) @type) -;; variables - -(class_parameter - name: (identifier) @parameter) +; variables +(class_parameter + name: (identifier) @variable.parameter) -(self_type (identifier) @parameter) +(self_type + (identifier) @variable.parameter) -(interpolation (identifier) @none) -(interpolation (block) @none) +(interpolation + (identifier) @none) -;; types +(interpolation + (block) @none) +; types (type_definition name: (type_identifier) @type.definition) (type_identifier) @type -;; val/var definitions/declarations - +; val/var definitions/declarations (val_definition pattern: (identifier) @variable) @@ -50,35 +50,46 @@ name: (identifier) @variable) ; method definition - (function_declaration - name: (identifier) @method) + name: (identifier) @function.method) (function_definition - name: (identifier) @method) + name: (identifier) @function.method) ; imports/exports - (import_declaration - path: (identifier) @namespace) -((stable_identifier (identifier) @namespace)) + path: (identifier) @module) + +(stable_identifier + (identifier) @module) ((import_declaration - path: (identifier) @type) (#match? @type "^[A-Z]")) -((stable_identifier (identifier) @type) (#match? @type "^[A-Z]")) + path: (identifier) @type) + (#match? @type "^[A-Z]")) + +((stable_identifier + (identifier) @type) + (#match? @type "^[A-Z]")) (export_declaration - path: (identifier) @namespace) -((stable_identifier (identifier) @namespace)) + path: (identifier) @module) + +(stable_identifier + (identifier) @module) ((export_declaration - path: (identifier) @type) (#match? @type "^[A-Z]")) -((stable_identifier (identifier) @type) (#match? @type "^[A-Z]")) + path: (identifier) @type) + (#match? @type "^[A-Z]")) -((namespace_selectors (identifier) @type) (#match? @type "^[A-Z]")) +((stable_identifier + (identifier) @type) + (#match? @type "^[A-Z]")) -; method invocation +((namespace_selectors + (identifier) @type) + (#match? @type "^[A-Z]")) +; method invocation (call_expression function: (identifier) @function.call) @@ -86,12 +97,13 @@ function: (operator_identifier) @function.call) (call_expression - function: (field_expression - field: (identifier) @method.call)) + function: + (field_expression + field: (identifier) @function.method.call)) ((call_expression - function: (identifier) @constructor) - (#match? @constructor "^[A-Z]")) + function: (identifier) @constructor) + (#match? @constructor "^[A-Z]")) (generic_function function: (identifier) @function.call) @@ -100,47 +112,61 @@ interpolator: (identifier) @function.call) ; function definitions - (function_definition name: (identifier) @function) (parameter - name: (identifier) @parameter) + name: (identifier) @variable.parameter) (binding - name: (identifier) @parameter) + name: (identifier) @variable.parameter) ; expressions +(field_expression + field: (identifier) @variable.member) -(field_expression field: (identifier) @property) -(field_expression value: (identifier) @type - (#match? @type "^[A-Z]")) +(field_expression + value: (identifier) @type + (#match? @type "^[A-Z]")) -(infix_expression operator: (identifier) @operator) -(infix_expression operator: (operator_identifier) @operator) -(infix_type operator: (operator_identifier) @operator) -(infix_type operator: (operator_identifier) @operator) +(infix_expression + operator: (identifier) @operator) -; literals +(infix_expression + operator: (operator_identifier) @operator) + +(infix_type + operator: (operator_identifier) @operator) + +(infix_type + operator: (operator_identifier) @operator) +; literals (boolean_literal) @boolean + (integer_literal) @number -(floating_point_literal) @float + +(floating_point_literal) @number.float [ - (symbol_literal) (string) - (character_literal) (interpolated_string_expression) ] @string -(interpolation "$" @punctuation.special) +(character_literal) @character + +(symbol_literal) @string.special.symbol -;; keywords +(interpolation + "$" @punctuation.special) +; keywords (opaque_modifier) @type.qualifier + (infix_modifier) @keyword + (transparent_modifier) @type.qualifier + (open_modifier) @type.qualifier [ @@ -150,8 +176,8 @@ "extends" "derives" "finally" -;; `forSome` existential types not implemented yet -;; `macro` not implemented yet + ; `forSome` existential types not implemented yet + ; `macro` not implemented yet "object" "override" "package" @@ -177,16 +203,15 @@ "protected" ] @type.qualifier -(inline_modifier) @storageclass +(inline_modifier) @keyword.storage (null_literal) @constant.builtin -(wildcard) @parameter +(wildcard) @variable.parameter (annotation) @attribute -;; special keywords - +; special keywords "new" @keyword.operator [ @@ -194,20 +219,20 @@ "if" "match" "then" -] @conditional +] @keyword.conditional [ - "(" - ")" - "[" - "]" - "{" - "}" -] @punctuation.bracket + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket [ - "." - "," + "." + "," ] @punctuation.delimiter [ @@ -215,47 +240,58 @@ "for" "while" "yield" -] @repeat +] @keyword.repeat "def" @keyword.function [ - "=>" - "<-" - "@" + "=>" + "<-" + "@" ] @operator -["import" "export"] @include +[ + "import" + "export" +] @keyword.import [ "try" "catch" "throw" -] @exception +] @keyword.exception "return" @keyword.return -(comment) @comment @spell -(block_comment) @comment @spell +[ + (comment) + (block_comment) +] @comment @spell -;; `case` is a conditional keyword in case_block +((block_comment) @comment.documentation + (#match? @comment.documentation "^/[*][*][^*].*[*]/$")) +; `case` is a conditional keyword in case_block (case_block - (case_clause ("case") @conditional)) + (case_clause + "case" @keyword.conditional)) + (indented_cases - (case_clause ("case") @conditional)) + (case_clause + "case" @keyword.conditional)) (operator_identifier) @operator -((identifier) @type (#match? @type "^[A-Z]")) +((identifier) @type + (#match? @type "^[A-Z]")) + ((identifier) @variable.builtin - (#match? @variable.builtin "^this$")) + (#match? @variable.builtin "^this$")) + +((identifier) @function.builtin + (#match? @function.builtin "^super$")) -( - (identifier) @function.builtin - (#match? @function.builtin "^super$") -) +; Scala CLI using directives +(using_directive_key) @variable.parameter -;; Scala CLI using directives -(using_directive_key) @parameter (using_directive_value) @string