diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2023-06-12 09:54:30 -0600 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2025-05-12 18:43:40 +0200 |
| commit | 692b051b09935653befdb8f7ba8afdb640adf17b (patch) | |
| tree | 167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/scala | |
| parent | feat(c-family): inherit injections (diff) | |
| download | nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2 nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip | |
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/scala')
| -rw-r--r-- | runtime/queries/scala/folds.scm | 16 | ||||
| -rw-r--r-- | runtime/queries/scala/highlights.scm | 311 | ||||
| -rw-r--r-- | runtime/queries/scala/injections.scm | 2 | ||||
| -rw-r--r-- | runtime/queries/scala/locals.scm | 49 |
4 files changed, 378 insertions, 0 deletions
diff --git a/runtime/queries/scala/folds.scm b/runtime/queries/scala/folds.scm new file mode 100644 index 000000000..b0f08188e --- /dev/null +++ b/runtime/queries/scala/folds.scm @@ -0,0 +1,16 @@ +(call_expression + (block) @fold) + +[ + (class_definition) + (trait_definition) + (object_definition) + (function_definition) + (val_definition) + (import_declaration) + (while_expression) + (do_while_expression) + (for_expression) + (try_expression) + (match_expression) +] @fold diff --git a/runtime/queries/scala/highlights.scm b/runtime/queries/scala/highlights.scm new file mode 100644 index 000000000..f85c502a4 --- /dev/null +++ b/runtime/queries/scala/highlights.scm @@ -0,0 +1,311 @@ +; 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 +(class_parameter + name: (identifier) @variable.parameter) + +(self_type + (identifier) @variable.parameter) + +(interpolation + (identifier) @none) + +(interpolation + (block) @none) + +; types +(type_definition + name: (type_identifier) @type.definition) + +(type_identifier) @type + +; val/var definitions/declarations +(val_definition + pattern: (identifier) @variable) + +(var_definition + pattern: (identifier) @variable) + +(val_declaration + name: (identifier) @variable) + +(var_declaration + name: (identifier) @variable) + +; method definition +(function_declaration + name: (identifier) @function.method) + +(function_definition + name: (identifier) @function.method) + +; imports/exports +(import_declaration + path: (identifier) @module) + +(stable_identifier + (identifier) @module) + +((import_declaration + path: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((stable_identifier + (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +(export_declaration + path: (identifier) @module) + +(stable_identifier + (identifier) @module) + +((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 +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (operator_identifier) @function.call) + +(call_expression + function: (field_expression + field: (identifier) @function.method.call)) + +((call_expression + function: (identifier) @constructor) + (#lua-match? @constructor "^[A-Z]")) + +(generic_function + function: (identifier) @function.call) + +(interpolated_string_expression + interpolator: (identifier) @function.call) + +; function definitions +(function_definition + name: (identifier) @function) + +(parameter + name: (identifier) @variable.parameter) + +(binding + name: (identifier) @variable.parameter) + +(lambda_expression + parameters: (identifier) @variable.parameter) + +; expressions +(field_expression + field: (identifier) @variable.member) + +(field_expression + value: (identifier) @type + (#lua-match? @type "^[A-Z]")) + +(infix_expression + operator: (identifier) @operator) + +(infix_expression + operator: (operator_identifier) @operator) + +(infix_type + operator: (operator_identifier) @operator) + +(infix_type + operator: (operator_identifier) @operator) + +; literals +(boolean_literal) @boolean + +(integer_literal) @number + +(floating_point_literal) @number.float + +[ + (string) + (interpolated_string_expression) +] @string + +(character_literal) @character + +(interpolation + "$" @punctuation.special) + +; keywords +(opaque_modifier) @keyword.modifier + +(infix_modifier) @keyword + +(transparent_modifier) @keyword.modifier + +(open_modifier) @keyword.modifier + +[ + "case" + "extends" + "derives" + "finally" + ; `forSome` existential types not implemented yet + ; `macro` not implemented yet + "object" + "override" + "val" + "var" + "with" + "given" + "using" + "end" + "implicit" + "extension" + "with" +] @keyword + +[ + "enum" + "class" + "trait" + "type" +] @keyword.type + +[ + "abstract" + "final" + "lazy" + "sealed" + "private" + "protected" +] @keyword.modifier + +(inline_modifier) @keyword.modifier + +(null_literal) @constant.builtin + +(wildcard + "_") @character.special + +(namespace_wildcard + [ + "*" + "_" + ] @character.special) + +(annotation) @attribute + +; special keywords +"new" @keyword.operator + +[ + "else" + "if" + "match" + "then" +] @keyword.conditional + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "." + "," + ":" +] @punctuation.delimiter + +[ + "do" + "for" + "while" + "yield" +] @keyword.repeat + +"def" @keyword.function + +[ + "=>" + "?=>" + "=" + "!" + "<-" + "@" +] @operator + +[ + "import" + "export" + "package" +] @keyword.import + +[ + "try" + "catch" + "throw" +] @keyword.exception + +"return" @keyword.return + +[ + (comment) + (block_comment) +] @comment @spell + +((block_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +; `case` is a conditional keyword in case_block +(case_block + (case_clause + "case" @keyword.conditional)) + +(case_block + (case_clause + "=>" @punctuation.delimiter)) + +(operator_identifier) @operator + +((identifier) @type + (#lua-match? @type "^[A-Z]")) + +((identifier) @variable.builtin + (#lua-match? @variable.builtin "^this$")) + +((identifier) @function.builtin + (#lua-match? @function.builtin "^super$")) + +; Scala CLI using directives +(using_directive_key) @variable.parameter + +(using_directive_value) @string diff --git a/runtime/queries/scala/injections.scm b/runtime/queries/scala/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/scala/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/scala/locals.scm b/runtime/queries/scala/locals.scm new file mode 100644 index 000000000..7128a4984 --- /dev/null +++ b/runtime/queries/scala/locals.scm @@ -0,0 +1,49 @@ +; Scopes +[ + (template_body) + (lambda_expression) + (function_definition) + (block) + (for_expression) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(function_declaration + name: (identifier) @local.definition.function) + +(function_definition + name: (identifier) @local.definition.function + (#set! definition.var.scope parent)) + +(parameter + name: (identifier) @local.definition.parameter) + +(class_parameter + name: (identifier) @local.definition.parameter) + +(lambda_expression + parameters: (identifier) @local.definition.var) + +(binding + name: (identifier) @local.definition.var) + +(val_definition + pattern: (identifier) @local.definition.var) + +(var_definition + pattern: (identifier) @local.definition.var) + +(val_declaration + name: (identifier) @local.definition.var) + +(var_declaration + name: (identifier) @local.definition.var) + +(for_expression + enumerators: (enumerators + (enumerator + (tuple_pattern + (identifier) @local.definition.var)))) |
