Skip to content

Sync with nvim-treesitter 77e2898e #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 116 additions & 80 deletions queries/scala/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
; CREDITS @stumash (stuart.mashaal@gmail.com)

(class_definition
name: (identifier) @type)

Expand All @@ -18,25 +17,26 @@
(simple_enum_case
name: (identifier) @type)

;; variables

(class_parameter
name: (identifier) @parameter)
; variables
(class_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)

(type_identifier) @type

;; val/var definitions/declarations

; val/var definitions/declarations
(val_definition
pattern: (identifier) @variable)

Expand All @@ -50,48 +50,60 @@
name: (identifier) @variable)

; method definition

(function_declaration
name: (identifier) @method)
name: (identifier) @function.method)

(function_definition
name: (identifier) @method)
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)
(#match? @type "^[A-Z]"))

((stable_identifier
(identifier) @type)
(#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)
(#match? @type "^[A-Z]"))

((namespace_selectors (identifier) @type) (#match? @type "^[A-Z]"))
((stable_identifier
(identifier) @type)
(#match? @type "^[A-Z]"))

; method invocation
((namespace_selectors
(identifier) @type)
(#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) @method.call))
function:
(field_expression
field: (identifier) @function.method.call))

((call_expression
function: (identifier) @constructor)
(#match? @constructor "^[A-Z]"))
function: (identifier) @constructor)
(#match? @constructor "^[A-Z]"))

(generic_function
function: (identifier) @function.call)
Expand All @@ -100,47 +112,61 @@
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)

; expressions
(field_expression
field: (identifier) @variable.member)

(field_expression field: (identifier) @property)
(field_expression value: (identifier) @type
(#match? @type "^[A-Z]"))
(field_expression
value: (identifier) @type
(#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)
(infix_expression
operator: (identifier) @operator)

; literals
(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) @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

;; keywords
(interpolation
"$" @punctuation.special)

; keywords
(opaque_modifier) @type.qualifier

(infix_modifier) @keyword

(transparent_modifier) @type.qualifier

(open_modifier) @type.qualifier

[
Expand All @@ -150,8 +176,8 @@
"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"
Expand All @@ -177,85 +203,95 @@
"protected"
] @type.qualifier

(inline_modifier) @storageclass
(inline_modifier) @keyword.storage

(null_literal) @constant.builtin

(wildcard) @parameter
(wildcard) @variable.parameter

(annotation) @attribute

;; special keywords

; 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"
] @keyword.import

[
"try"
"catch"
"throw"
] @exception
] @keyword.exception

"return" @keyword.return

(comment) @comment @spell
(block_comment) @comment @spell
[
(comment)
(block_comment)
] @comment @spell

;; `case` is a conditional keyword in case_block
((block_comment) @comment.documentation
(#match? @comment.documentation "^/[*][*][^*].*[*]/$"))

; `case` is a conditional keyword in case_block
(case_block
(case_clause ("case") @conditional))
(case_clause
"case" @keyword.conditional))

(indented_cases
(case_clause ("case") @conditional))
(case_clause
"case" @keyword.conditional))

(operator_identifier) @operator

((identifier) @type (#match? @type "^[A-Z]"))
((identifier) @type
(#match? @type "^[A-Z]"))

((identifier) @variable.builtin
(#match? @variable.builtin "^this$"))
(#match? @variable.builtin "^this$"))

((identifier) @function.builtin
(#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