nvim-treesitter/queries/java/highlights.scm

302 lines
4 KiB
Scheme
Raw Normal View History

2020-06-17 18:01:29 +05:30
; CREDITS @maxbrunsfeld (maxbrunsfeld@gmail.com)
; Variables
2020-06-11 22:31:45 +05:30
(identifier) @variable
; Methods
2020-06-11 22:31:45 +05:30
(method_declaration
2020-06-15 21:48:50 +05:30
name: (identifier) @method)
2020-06-11 22:31:45 +05:30
(method_invocation
name: (identifier) @method.call)
2020-06-11 22:31:45 +05:30
(super) @function.builtin
; Parameters
(formal_parameter
name: (identifier) @parameter)
(catch_formal_parameter
name: (identifier) @parameter)
(spread_parameter
(variable_declarator
name: (identifier) @parameter)) ; int... foo
;; Lambda parameter
(inferred_parameters (identifier) @parameter) ; (x,y) -> ...
(lambda_expression
parameters: (identifier) @parameter) ; x -> ...
2020-06-11 22:31:45 +05:30
; Annotations
(annotation
2023-10-13 23:08:05 +02:00
"@" @attribute
2020-06-11 22:31:45 +05:30
name: (identifier) @attribute)
(marker_annotation
2023-10-13 23:08:05 +02:00
"@" @attribute
2020-06-11 22:31:45 +05:30
name: (identifier) @attribute)
2020-06-15 22:45:56 +05:30
; Operators
2020-06-15 22:45:56 +05:30
[
"+"
":"
"++"
"-"
"--"
"&"
"&&"
"|"
"||"
"!"
"!="
"=="
"*"
"/"
"%"
"<"
"<="
">"
">="
"="
"-="
"+="
"*="
"/="
"%="
"->"
"^"
"^="
"&="
"|="
"~"
">>"
">>>"
"<<"
"::"
2020-06-15 22:45:56 +05:30
] @operator
2020-06-11 22:31:45 +05:30
; Types
(interface_declaration
name: (identifier) @type)
(annotation_type_declaration
name: (identifier) @type)
2020-06-11 22:31:45 +05:30
(class_declaration
name: (identifier) @type)
(record_declaration
name: (identifier) @type)
2020-06-11 22:31:45 +05:30
(enum_declaration
name: (identifier) @type)
(constructor_declaration
name: (identifier) @type)
(type_identifier) @type
((type_identifier) @type.builtin
(#eq? @type.builtin "var"))
((method_invocation
object: (identifier) @type)
(#lua-match? @type "^[A-Z]"))
((method_reference
. (identifier) @type)
(#lua-match? @type "^[A-Z]"))
2020-06-11 22:31:45 +05:30
((field_access
object: (identifier) @type)
(#lua-match? @type "^[A-Z]"))
(scoped_identifier
(identifier) @type
(#lua-match? @type "^[A-Z]"))
2020-06-11 22:31:45 +05:30
; Fields
(field_declaration
declarator: (variable_declarator
name: (identifier) @field))
(field_access
field: (identifier) @field)
[
(boolean_type)
(integral_type)
(floating_point_type)
(void_type)
] @type.builtin
2020-06-11 22:31:45 +05:30
; Variables
((identifier) @constant
(#lua-match? @constant "^[A-Z_][A-Z%d_]+$"))
2020-06-11 22:31:45 +05:30
(this) @variable.builtin
2020-06-11 22:31:45 +05:30
; Literals
(string_literal) @string
(escape_sequence) @string.escape
2020-06-15 23:23:17 +05:30
(character_literal) @character
2020-06-11 22:31:45 +05:30
[
(hex_integer_literal)
(decimal_integer_literal)
(octal_integer_literal)
(binary_integer_literal)
] @number
2020-06-11 22:31:45 +05:30
[
(decimal_floating_point_literal)
(hex_floating_point_literal)
] @float
[
(true)
(false)
2020-06-11 22:31:45 +05:30
] @boolean
(null_literal) @constant.builtin
2020-06-11 22:31:45 +05:30
; Keywords
[
"assert"
"class"
"record"
"default"
"enum"
"extends"
"implements"
"instanceof"
"interface"
"@interface"
"permits"
"to"
"with"
] @keyword
(synchronized_statement
"synchronized" @keyword)
[
"abstract"
"final"
"native"
"non-sealed"
"open"
"private"
"protected"
"public"
"sealed"
"static"
"strictfp"
"transitive"
] @type.qualifier
(modifiers
"synchronized" @type.qualifier)
[
"transient"
"volatile"
] @storageclass
2020-06-11 22:31:45 +05:30
[
"return"
"yield"
] @keyword.return
[
"new"
] @keyword.operator
2020-06-11 22:31:45 +05:30
; Conditionals
[
"if"
"else"
"switch"
"case"
2020-06-11 22:31:45 +05:30
] @conditional
(ternary_expression ["?" ":"] @conditional.ternary)
2020-11-19 16:03:58 +05:30
; Loops
2020-06-11 22:31:45 +05:30
[
"for"
"while"
"do"
"continue"
"break"
2020-06-11 22:31:45 +05:30
] @repeat
; Includes
2020-06-11 22:31:45 +05:30
[
"exports"
"import"
"module"
"opens"
"package"
"provides"
"requires"
"uses"
] @include
2020-06-11 22:31:45 +05:30
; Punctuation
[
";"
"."
"..."
","
] @punctuation.delimiter
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
[ "(" ")" ] @punctuation.bracket
2020-08-16 10:26:11 +05:30
(type_arguments [ "<" ">" ] @punctuation.bracket)
(type_parameters [ "<" ">" ] @punctuation.bracket)
(string_interpolation [ "\\{" "}" ] @punctuation.special)
; Exceptions
[
"throw"
"throws"
"finally"
"try"
"catch"
] @exception
2020-08-16 10:26:11 +05:30
; Labels
2020-08-16 10:26:11 +05:30
(labeled_statement
(identifier) @label)
; Comments
[
(line_comment)
(block_comment)
] @comment @spell
((block_comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))