diff --git a/queries/highlights.scm b/queries/highlights.scm index 7f26e1b..3ff6430 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -1,11 +1,4 @@ ; CREDITS @stumash (stuart.mashaal@gmail.com) - -(field_expression field: (identifier) @property) -(field_expression value: (identifier) @type - (#match? @type "^[A-Z]")) - -(type_identifier) @type - (class_definition name: (identifier) @type) @@ -24,23 +17,26 @@ (simple_enum_case name: (identifier) @type) -;; variables - +; variables (class_parameter - name: (identifier) @parameter) + name: (identifier) @variable.parameter) -(self_type (identifier) @parameter) +(self_type + (identifier) @variable.parameter) -(interpolation (identifier) @none) -(interpolation (block) @none) +(interpolation + (identifier) @none) -;; types +(interpolation + (block) @none) +; types (type_definition name: (type_identifier) @type.definition) -;; val/var definitions/declarations +(type_identifier) @type +; val/var definitions/declarations (val_definition pattern: (identifier) @variable) @@ -53,28 +49,47 @@ (var_declaration name: (identifier) @variable) -; imports/exports +; method definition +(function_declaration + name: (identifier) @function.method) + +(function_definition + name: (identifier) @function.method) +; imports/exports (import_declaration - path: (identifier) @namespace) -((stable_identifier (identifier) @namespace)) + path: (identifier) @module) + +(stable_identifier + (identifier) @module) ((import_declaration - path: (identifier) @type) (#match? @type "^[A-Z]")) -((stable_identifier (identifier) @type) (#match? @type "^[A-Z]")) + path: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((stable_identifier + (identifier) @type) + (#lua-match? @type "^[A-Z]")) (export_declaration - path: (identifier) @namespace) -((stable_identifier (identifier) @namespace)) + path: (identifier) @module) + +(stable_identifier + (identifier) @module) ((export_declaration - path: (identifier) @type) (#match? @type "^[A-Z]")) -((stable_identifier (identifier) @type) (#match? @type "^[A-Z]")) + path: (identifier) @type) + (#lua-match? @type "^[A-Z]")) -((namespace_selectors (identifier) @type) (#match? @type "^[A-Z]")) +((stable_identifier + (identifier) @type) + (#lua-match? @type "^[A-Z]")) -; method invocation +((namespace_selectors + (identifier) @type) + (#lua-match? @type "^[A-Z]")) +; method invocation (call_expression function: (identifier) @function.call) @@ -83,11 +98,11 @@ (call_expression function: (field_expression - field: (identifier) @method.call)) + field: (identifier) @function.method.call)) ((call_expression - function: (identifier) @constructor) - (#match? @constructor "^[A-Z]")) + function: (identifier) @constructor) + (#lua-match? @constructor "^[A-Z]")) (generic_function function: (identifier) @function.call) @@ -96,67 +111,75 @@ interpolator: (identifier) @function.call) ; function definitions - (function_definition name: (identifier) @function) (parameter - name: (identifier) @parameter) + name: (identifier) @variable.parameter) (binding - name: (identifier) @parameter) + name: (identifier) @variable.parameter) -; method definition +(lambda_expression + parameters: (identifier) @variable.parameter) -(function_declaration - name: (identifier) @method) +; expressions +(field_expression + field: (identifier) @variable.member) -(function_definition - name: (identifier) @method) +(field_expression + value: (identifier) @type + (#lua-match? @type "^[A-Z]")) -; expressions +(infix_expression + operator: (identifier) @operator) -(infix_expression operator: (identifier) @operator) -(infix_expression operator: (operator_identifier) @operator) -(infix_type operator: (operator_identifier) @operator) -(infix_type operator: (operator_identifier) @operator) +(infix_expression + operator: (operator_identifier) @operator) -; literals +(infix_type + operator: (operator_identifier) @operator) + +(infix_type + operator: (operator_identifier) @operator) +; literals (boolean_literal) @boolean + (integer_literal) @number -(floating_point_literal) @float + +(floating_point_literal) @number.float [ - (symbol_literal) (string) - (character_literal) (interpolated_string_expression) ] @string -(interpolation "$" @punctuation.special) +(character_literal) @character + +(symbol_literal) @string.special.symbol + +(interpolation + "$" @punctuation.special) -;; keywords +; keywords +(opaque_modifier) @keyword.modifier -(opaque_modifier) @type.qualifier (infix_modifier) @keyword -(transparent_modifier) @type.qualifier -(open_modifier) @type.qualifier + +(transparent_modifier) @keyword.modifier + +(open_modifier) @keyword.modifier [ "case" - "class" - "enum" "extends" "derives" "finally" -;; `forSome` existential types not implemented yet -;; `macro` not implemented yet + ; `forSome` existential types not implemented yet + ; `macro` not implemented yet "object" "override" - "package" - "trait" - "type" "val" "var" "with" @@ -168,6 +191,13 @@ "with" ] @keyword +[ + "enum" + "class" + "trait" + "type" +] @keyword.type + [ "abstract" "final" @@ -175,18 +205,23 @@ "sealed" "private" "protected" -] @type.qualifier +] @keyword.modifier -(inline_modifier) @storageclass +(inline_modifier) @keyword.modifier (null_literal) @constant.builtin -(wildcard) @parameter +(wildcard) @variable.parameter -(annotation) @attribute +(namespace_wildcard + [ + "*" + "_" + ] @character.special) -;; special keywords +(annotation) @attribute +; special keywords "new" @keyword.operator [ @@ -194,20 +229,21 @@ "if" "match" "then" -] @conditional +] @keyword.conditional [ - "(" - ")" - "[" - "]" - "{" - "}" -] @punctuation.bracket + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket [ - "." - "," + "." + "," + ":" ] @punctuation.delimiter [ @@ -215,47 +251,62 @@ "for" "while" "yield" -] @repeat +] @keyword.repeat "def" @keyword.function [ - "=>" - "<-" - "@" + "=>" + "?=>" + "=" + "!" + "<-" + "@" ] @operator -["import" "export"] @include +[ + "import" + "export" + "package" +] @keyword.import [ "try" "catch" "throw" -] @exception +] @keyword.exception "return" @keyword.return -(comment) @spell @comment -(block_comment) @spell @comment +[ + (comment) + (block_comment) +] @comment @spell + +((block_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) -;; `case` is a conditional keyword in case_block +; `case` is a conditional keyword in case_block +(case_block + (case_clause + "case" @keyword.conditional)) (case_block - (case_clause ("case") @conditional)) -(indented_cases - (case_clause ("case") @conditional)) + (case_clause + "=>" @punctuation.delimiter)) (operator_identifier) @operator -((identifier) @type (#match? @type "^[A-Z]")) +((identifier) @type + (#lua-match? @type "^[A-Z]")) + ((identifier) @variable.builtin - (#match? @variable.builtin "^this$")) + (#lua-match? @variable.builtin "^this$")) + +((identifier) @function.builtin + (#lua-match? @function.builtin "^super$")) -( - (identifier) @function.builtin - (#match? @function.builtin "^super$") -) +; Scala CLI using directives +(using_directive_key) @variable.parameter -;; Scala CLI using directives -(using_directive_key) @parameter (using_directive_value) @string diff --git a/queries/injections.scm b/queries/injections.scm new file mode 100644 index 0000000..1c2fe3c --- /dev/null +++ b/queries/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((block_comment) @injection.content + (#set! injection.language "comment")) diff --git a/queries/locals.scm b/queries/locals.scm index c5027b5..7128a49 100644 --- a/queries/locals.scm +++ b/queries/locals.scm @@ -1,30 +1,49 @@ -(template_body) @local.scope -(lambda_expression) @local.scope - +; Scopes +[ + (template_body) + (lambda_expression) + (function_definition) + (block) + (for_expression) +] @local.scope + +; References +(identifier) @local.reference +; Definitions (function_declaration - name: (identifier) @local.definition) @local.scope + name: (identifier) @local.definition.function) (function_definition - name: (identifier) @local.definition) + name: (identifier) @local.definition.function + (#set! definition.var.scope parent)) (parameter - name: (identifier) @local.definition) + name: (identifier) @local.definition.parameter) + +(class_parameter + name: (identifier) @local.definition.parameter) + +(lambda_expression + parameters: (identifier) @local.definition.var) (binding - name: (identifier) @local.definition) + name: (identifier) @local.definition.var) (val_definition - pattern: (identifier) @local.definition) + pattern: (identifier) @local.definition.var) (var_definition - pattern: (identifier) @local.definition) + pattern: (identifier) @local.definition.var) (val_declaration - name: (identifier) @local.definition) + name: (identifier) @local.definition.var) (var_declaration - name: (identifier) @local.definition) - -(identifier) @local.reference + name: (identifier) @local.definition.var) +(for_expression + enumerators: (enumerators + (enumerator + (tuple_pattern + (identifier) @local.definition.var))))