diff options
| author | Stevan Milic <stevan.milic@tradecore.com> | 2021-09-01 16:55:53 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2021-09-17 21:06:36 +0200 |
| commit | bb7fa60165625f24b58d246dfe295ac9eef3a9ea (patch) | |
| tree | e7d7c59cefddb3f5b7b0f478cde7c0200f02f307 | |
| parent | Update lockfile.json (#1779) (diff) | |
| download | nvim-treesitter-bb7fa60165625f24b58d246dfe295ac9eef3a9ea.tar nvim-treesitter-bb7fa60165625f24b58d246dfe295ac9eef3a9ea.tar.gz nvim-treesitter-bb7fa60165625f24b58d246dfe295ac9eef3a9ea.tar.bz2 nvim-treesitter-bb7fa60165625f24b58d246dfe295ac9eef3a9ea.tar.lz nvim-treesitter-bb7fa60165625f24b58d246dfe295ac9eef3a9ea.tar.xz nvim-treesitter-bb7fa60165625f24b58d246dfe295ac9eef3a9ea.tar.zst nvim-treesitter-bb7fa60165625f24b58d246dfe295ac9eef3a9ea.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
| -rw-r--r-- | queries/scala/highlights.scm | 36 | ||||
| -rw-r--r-- | queries/scala/injections.scm | 1 |
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 |
