mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-09 06:50:06 -04:00
Update scala highlights
* add highlights for imports * add highlights for type constructors * add highlights for constants * add highlights for interpolation string * add highlights for comments through injection
This commit is contained in:
parent
f0ea4788b0
commit
bb7fa60165
2 changed files with 36 additions and 1 deletions
|
|
@ -7,6 +7,15 @@
|
||||||
((identifier) @variable.builtin
|
((identifier) @variable.builtin
|
||||||
(#match? @variable.builtin "^this$"))
|
(#match? @variable.builtin "^this$"))
|
||||||
|
|
||||||
|
; Assume other uppercase names constants.
|
||||||
|
; NOTE: In order to distinguish constants we highlight
|
||||||
|
; all the identifiers that are uppercased. But this solution
|
||||||
|
; is not suitable for all occurences e.g. it will highlight
|
||||||
|
; an uppercased method as a constant if used with no params.
|
||||||
|
; Introducing highlighting for those specifi cases, is probably
|
||||||
|
; best way to resolve the issue.
|
||||||
|
((identifier) @constant (#match? @constant "^[A-Z]"))
|
||||||
|
|
||||||
;; types
|
;; types
|
||||||
|
|
||||||
(type_identifier) @type
|
(type_identifier) @type
|
||||||
|
|
@ -38,8 +47,21 @@
|
||||||
(function_definition
|
(function_definition
|
||||||
name: (identifier) @method)))
|
name: (identifier) @method)))
|
||||||
|
|
||||||
|
; imports
|
||||||
|
|
||||||
|
(import_declaration
|
||||||
|
path: (identifier) @namespace)
|
||||||
|
((stable_identifier (identifier) @namespace))
|
||||||
|
|
||||||
|
((import_declaration
|
||||||
|
path: (identifier) @type) (#match? @type "^[A-Z]"))
|
||||||
|
((stable_identifier (identifier) @type) (#match? @type "^[A-Z]"))
|
||||||
|
|
||||||
|
((import_selectors (identifier) @type) (#match? @type "^[A-Z]"))
|
||||||
|
|
||||||
; method invocation
|
; method invocation
|
||||||
|
|
||||||
|
|
||||||
(call_expression
|
(call_expression
|
||||||
function: (identifier) @function)
|
function: (identifier) @function)
|
||||||
|
|
||||||
|
|
@ -47,6 +69,10 @@
|
||||||
function: (field_expression
|
function: (field_expression
|
||||||
field: (identifier) @method))
|
field: (identifier) @method))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (identifier) @constructor)
|
||||||
|
(#match? @constructor "^[A-Z]"))
|
||||||
|
|
||||||
(generic_function
|
(generic_function
|
||||||
function: (identifier) @function)
|
function: (identifier) @function)
|
||||||
|
|
||||||
|
|
@ -65,7 +91,10 @@
|
||||||
|
|
||||||
; expressions
|
; expressions
|
||||||
|
|
||||||
|
|
||||||
(field_expression field: (identifier) @property)
|
(field_expression field: (identifier) @property)
|
||||||
|
(field_expression value: (identifier) @type
|
||||||
|
(#match? @type "^[A-Z]"))
|
||||||
|
|
||||||
(infix_expression operator: (identifier) @operator)
|
(infix_expression operator: (identifier) @operator)
|
||||||
(infix_expression operator: (operator_identifier) @operator)
|
(infix_expression operator: (operator_identifier) @operator)
|
||||||
|
|
@ -77,14 +106,17 @@
|
||||||
(boolean_literal) @boolean
|
(boolean_literal) @boolean
|
||||||
(integer_literal) @number
|
(integer_literal) @number
|
||||||
(floating_point_literal) @float
|
(floating_point_literal) @float
|
||||||
(string) @string
|
|
||||||
|
|
||||||
[
|
[
|
||||||
(symbol_literal)
|
(symbol_literal)
|
||||||
(string)
|
(string)
|
||||||
(character_literal)
|
(character_literal)
|
||||||
|
(interpolated_string_expression)
|
||||||
] @string
|
] @string
|
||||||
|
|
||||||
|
(interpolation "$" @punctuation.special)
|
||||||
|
(interpolation (identifier) @variable)
|
||||||
|
|
||||||
;; keywords
|
;; keywords
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
@ -112,6 +144,7 @@
|
||||||
] @keyword
|
] @keyword
|
||||||
|
|
||||||
(null_literal) @keyword
|
(null_literal) @keyword
|
||||||
|
(wildcard) @keyword
|
||||||
|
|
||||||
;; special keywords
|
;; special keywords
|
||||||
|
|
||||||
|
|
@ -149,6 +182,7 @@
|
||||||
[
|
[
|
||||||
"=>"
|
"=>"
|
||||||
"<-"
|
"<-"
|
||||||
|
"@"
|
||||||
] @operator
|
] @operator
|
||||||
|
|
||||||
"import" @include
|
"import" @include
|
||||||
|
|
|
||||||
1
queries/scala/injections.scm
Normal file
1
queries/scala/injections.scm
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
(comment) @comment
|
||||||
Loading…
Add table
Add a link
Reference in a new issue