From bb7fa60165625f24b58d246dfe295ac9eef3a9ea Mon Sep 17 00:00:00 2001 From: Stevan Milic Date: Wed, 1 Sep 2021 16:55:53 +0200 Subject: Update scala highlights * add highlights for imports * add highlights for type constructors * add highlights for constants * add highlights for interpolation string * add highlights for comments through injection --- queries/scala/highlights.scm | 36 +++++++++++++++++++++++++++++++++++- queries/scala/injections.scm | 1 + 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 queries/scala/injections.scm (limited to 'queries') diff --git a/queries/scala/highlights.scm b/queries/scala/highlights.scm index 544780857..a7546fa49 100644 --- a/queries/scala/highlights.scm +++ b/queries/scala/highlights.scm @@ -7,6 +7,15 @@ ((identifier) @variable.builtin (#match? @variable.builtin "^this$")) +; Assume other uppercase names constants. +; NOTE: In order to distinguish constants we highlight +; all the identifiers that are uppercased. But this solution +; is not suitable for all occurences e.g. it will highlight +; an uppercased method as a constant if used with no params. +; Introducing highlighting for those specifi cases, is probably +; best way to resolve the issue. +((identifier) @constant (#match? @constant "^[A-Z]")) + ;; types (type_identifier) @type @@ -38,8 +47,21 @@ (function_definition name: (identifier) @method))) +; imports + +(import_declaration + path: (identifier) @namespace) +((stable_identifier (identifier) @namespace)) + +((import_declaration + path: (identifier) @type) (#match? @type "^[A-Z]")) +((stable_identifier (identifier) @type) (#match? @type "^[A-Z]")) + +((import_selectors (identifier) @type) (#match? @type "^[A-Z]")) + ; method invocation + (call_expression function: (identifier) @function) @@ -47,6 +69,10 @@ function: (field_expression field: (identifier) @method)) +((call_expression + function: (identifier) @constructor) + (#match? @constructor "^[A-Z]")) + (generic_function function: (identifier) @function) @@ -65,7 +91,10 @@ ; expressions + (field_expression field: (identifier) @property) +(field_expression value: (identifier) @type + (#match? @type "^[A-Z]")) (infix_expression operator: (identifier) @operator) (infix_expression operator: (operator_identifier) @operator) @@ -77,14 +106,17 @@ (boolean_literal) @boolean (integer_literal) @number (floating_point_literal) @float -(string) @string [ (symbol_literal) (string) (character_literal) +(interpolated_string_expression) ] @string +(interpolation "$" @punctuation.special) +(interpolation (identifier) @variable) + ;; keywords [ @@ -112,6 +144,7 @@ ] @keyword (null_literal) @keyword +(wildcard) @keyword ;; special keywords @@ -149,6 +182,7 @@ [ "=>" "<-" + "@" ] @operator "import" @include diff --git a/queries/scala/injections.scm b/queries/scala/injections.scm new file mode 100644 index 000000000..4bb7d675d --- /dev/null +++ b/queries/scala/injections.scm @@ -0,0 +1 @@ +(comment) @comment -- cgit v1.2.3-70-g09d2