diff options
| author | Chris Kipp <ckipp@pm.me> | 2023-01-12 12:52:44 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2023-01-14 12:56:56 -0800 |
| commit | add6f9abe2d8b3f76b8bc0116bdd1d5f8a24f9fd (patch) | |
| tree | 70078366711e0305f83a3419e3674021ef46bed4 /queries | |
| parent | ci: stop running update-lockfile after every commit (diff) | |
| download | nvim-treesitter-add6f9abe2d8b3f76b8bc0116bdd1d5f8a24f9fd.tar nvim-treesitter-add6f9abe2d8b3f76b8bc0116bdd1d5f8a24f9fd.tar.gz nvim-treesitter-add6f9abe2d8b3f76b8bc0116bdd1d5f8a24f9fd.tar.bz2 nvim-treesitter-add6f9abe2d8b3f76b8bc0116bdd1d5f8a24f9fd.tar.lz nvim-treesitter-add6f9abe2d8b3f76b8bc0116bdd1d5f8a24f9fd.tar.xz nvim-treesitter-add6f9abe2d8b3f76b8bc0116bdd1d5f8a24f9fd.tar.zst nvim-treesitter-add6f9abe2d8b3f76b8bc0116bdd1d5f8a24f9fd.zip | |
refactor(scala): update the Scala highlight queries
There has been a lot of changes recently to the Scala grammar and we've
been merging in a handful of things before syncing the actual generated
parser. We are currently at a stage where we're going to sync
everything, but there are some breaking changes that are included in
https://github.com/tree-sitter/tree-sitter-scala/pull/135, so when that
commit gets synced here stuff will break. We've taken the queries that
existed here and have been building off of them in the actual upstream
repo. This will hopefully make the transition smooth and updates the
queries to ensure that there is no breakage. It's recommended to wait
until that pr is merged, synced here, and then merge this in around the
same time.
Co-authored-by: eugene yokota <eed3si9n@gmail.com>
Co-authored-by: Anton Sviridov <keynmol@gmail.com>
Diffstat (limited to 'queries')
| -rw-r--r-- | queries/scala/highlights.scm | 132 |
1 files changed, 85 insertions, 47 deletions
diff --git a/queries/scala/highlights.scm b/queries/scala/highlights.scm index 2ae5b17c4..8cf7f3dbd 100644 --- a/queries/scala/highlights.scm +++ b/queries/scala/highlights.scm @@ -1,55 +1,62 @@ ; CREDITS @stumash (stuart.mashaal@gmail.com) +(class_definition + name: (identifier) @type) + +(enum_definition + name: (identifier) @type) + +(object_definition + name: (identifier) @type) + +(trait_definition + name: (identifier) @type) + +(full_enum_case + name: (identifier) @type) + +(simple_enum_case + name: (identifier) @type) + ;; variables -(identifier) @variable +(class_parameter + name: (identifier) @parameter) -((identifier) @variable.builtin - (#lua-match? @variable.builtin "^this$")) (interpolation) @none -; 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 occurrences e.g. it will highlight -; an uppercased method as a constant if used with no params. -; Introducing highlighting for those specific cases, is probably -; best way to resolve the issue. -((identifier) @constant (#lua-match? @constant "^[A-Z]")) - ;; types +(type_definition + name: (type_identifier) @type.definition) + (type_identifier) @type -(class_definition - name: (identifier) @type) -(object_definition - name: (identifier) @type) +;; val/var definitions/declarations -(trait_definition - name: (identifier) @type) +(val_definition + pattern: (identifier) @variable) -(type_definition - name: (type_identifier) @type.definition) +(var_definition + pattern: (identifier) @variable) + +(val_declaration + name: (identifier) @variable) + +(var_declaration + name: (identifier) @variable) ; method definition -(class_definition - body: (template_body - (function_definition - name: (identifier) @method))) -(object_definition - body: (template_body - (function_definition - name: (identifier) @method))) -(trait_definition - body: (template_body - (function_definition - name: (identifier) @method))) +(function_declaration + name: (identifier) @method) + +(function_definition + name: (identifier) @method) -; imports +; imports/exports (import_declaration path: (identifier) @namespace) @@ -59,7 +66,15 @@ path: (identifier) @type) (#lua-match? @type "^[A-Z]")) ((stable_identifier (identifier) @type) (#lua-match? @type "^[A-Z]")) -((import_selectors (identifier) @type) (#lua-match? @type "^[A-Z]")) +(export_declaration + path: (identifier) @namespace) +((stable_identifier (identifier) @namespace)) + +((export_declaration + path: (identifier) @type) (#lua-match? @type "^[A-Z]")) +((stable_identifier (identifier) @type) (#lua-match? @type "^[A-Z]")) + +((namespace_selectors (identifier) @type) (#lua-match? @type "^[A-Z]")) ; method invocation @@ -68,6 +83,9 @@ function: (identifier) @function.call) (call_expression + function: (operator_identifier) @function.call) + +(call_expression function: (field_expression field: (identifier) @method.call)) @@ -78,11 +96,6 @@ (generic_function function: (identifier) @function.call) -( - (identifier) @function.builtin - (#lua-match? @function.builtin "^super$") -) - ; function definitions (function_definition @@ -93,7 +106,6 @@ ; expressions - (field_expression field: (identifier) @property) (field_expression value: (identifier) @type (#lua-match? @type "^[A-Z]")) @@ -110,20 +122,27 @@ (floating_point_literal) @float [ -(symbol_literal) -(string) -(character_literal) -(interpolated_string_expression) + (symbol_literal) + (string) + (character_literal) + (interpolated_string_expression) ] @string (interpolation "$" @punctuation.special) ;; keywords +(opaque_modifier) @type.qualifier +(infix_modifier) @keyword +(transparent_modifier) @type.qualifier +(open_modifier) @type.qualifier + [ "case" "class" + "enum" "extends" + "derives" "finally" ;; `forSome` existential types not implemented yet ;; `macro` not implemented yet @@ -135,18 +154,25 @@ "val" "var" "with" + "given" + "using" + "end" + "implicit" + "extension" + "with" ] @keyword [ "abstract" "final" - "implicit" "lazy" + "sealed" "private" "protected" - "sealed" ] @type.qualifier +(inline_modifier) @storageclass + (null_literal) @constant.builtin (wildcard) @parameter @@ -161,6 +187,7 @@ "else" "if" "match" + "then" ] @conditional [ @@ -192,7 +219,7 @@ "@" ] @operator -"import" @include +["import" "export"] @include [ "try" @@ -208,3 +235,14 @@ (case_block (case_clause ("case") @conditional)) + +(operator_identifier) @operator + +((identifier) @constant (#lua-match? @constant "^[A-Z]")) +((identifier) @variable.builtin + (#lua-match? @variable.builtin "^this$")) + +( + (identifier) @function.builtin + (#lua-match? @function.builtin "^super$") +) |
