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
This commit is contained in:
Stevan Milic 2021-09-01 16:55:53 +02:00 committed by Stephan Seitz
parent f0ea4788b0
commit bb7fa60165
2 changed files with 36 additions and 1 deletions

View file

@ -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

View file

@ -0,0 +1 @@
(comment) @comment