Skip to content

Commit

Permalink
Copy queries
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Sep 11, 2024
1 parent 6b819dc commit 86ef358
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 106 deletions.
237 changes: 144 additions & 93 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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"
Expand All @@ -168,94 +191,122 @@
"with"
] @keyword

[
"enum"
"class"
"trait"
"type"
] @keyword.type

[
"abstract"
"final"
"lazy"
"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

[
"else"
"if"
"match"
"then"
] @conditional
] @keyword.conditional

[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket

[
"."
","
"."
","
":"
] @punctuation.delimiter

[
"do"
"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
5 changes: 5 additions & 0 deletions queries/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
((comment) @injection.content
(#set! injection.language "comment"))

((block_comment) @injection.content
(#set! injection.language "comment"))
Loading

0 comments on commit 86ef358

Please sign in to comment.