aboutsummaryrefslogtreecommitdiffstats
path: root/queries/scala
diff options
context:
space:
mode:
authorStevan Milic <stevan.milic@tradecore.com>2021-09-01 16:55:53 +0200
committerStephan Seitz <stephan.seitz@fau.de>2021-09-04 04:36:30 +0200
commit59f881fff8da25e97f8a2e252c3a45ae131ac35d (patch)
treee7d7c59cefddb3f5b7b0f478cde7c0200f02f307 /queries/scala
parentUpdate lockfile.json (#1779) (diff)
downloadnvim-treesitter-59f881fff8da25e97f8a2e252c3a45ae131ac35d.tar
nvim-treesitter-59f881fff8da25e97f8a2e252c3a45ae131ac35d.tar.gz
nvim-treesitter-59f881fff8da25e97f8a2e252c3a45ae131ac35d.tar.bz2
nvim-treesitter-59f881fff8da25e97f8a2e252c3a45ae131ac35d.tar.lz
nvim-treesitter-59f881fff8da25e97f8a2e252c3a45ae131ac35d.tar.xz
nvim-treesitter-59f881fff8da25e97f8a2e252c3a45ae131ac35d.tar.zst
nvim-treesitter-59f881fff8da25e97f8a2e252c3a45ae131ac35d.zip
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
Diffstat (limited to 'queries/scala')
-rw-r--r--queries/scala/highlights.scm36
-rw-r--r--queries/scala/injections.scm1
2 files changed, 36 insertions, 1 deletions
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