mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-06 05:20:00 -04:00
Simplify vala highlights.scm
This commit is contained in:
parent
a162d42175
commit
3f046500ae
1 changed files with 73 additions and 176 deletions
|
|
@ -1,21 +1,8 @@
|
|||
; Pointers
|
||||
|
||||
(address_of_identifier
|
||||
"&" @symbol
|
||||
(_)*
|
||||
)
|
||||
|
||||
(pointer_type
|
||||
(_)*
|
||||
"*" @symbol
|
||||
)
|
||||
|
||||
(indirection_identifier
|
||||
"*" @symbol
|
||||
(_)*
|
||||
)
|
||||
|
||||
"delete" @keyword
|
||||
(address_of_identifier "&" @symbol)
|
||||
(pointer_type "*" @symbol)
|
||||
(indirection_identifier "*" @symbol)
|
||||
|
||||
; Misc
|
||||
|
||||
|
|
@ -29,27 +16,68 @@
|
|||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
";"
|
||||
"."
|
||||
","
|
||||
"->"
|
||||
";"
|
||||
"."
|
||||
","
|
||||
"->"
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Keywords
|
||||
; Reserved keywords
|
||||
|
||||
"return" @keyword.return
|
||||
"yield" @keyword.return
|
||||
"break" @keyword.return
|
||||
[
|
||||
"return"
|
||||
"yield"
|
||||
"break"
|
||||
] @keyword.return
|
||||
|
||||
; Booleans
|
||||
[
|
||||
(null)
|
||||
(modifier)
|
||||
"typeof"
|
||||
"is"
|
||||
"var"
|
||||
"class"
|
||||
"interface"
|
||||
(property_parameter)
|
||||
(this)
|
||||
"enum"
|
||||
"new"
|
||||
"in"
|
||||
"as"
|
||||
"try"
|
||||
"catch"
|
||||
"requires"
|
||||
"ensures"
|
||||
"owned"
|
||||
"throws"
|
||||
"delete"
|
||||
] @keyword
|
||||
|
||||
(true) @boolean
|
||||
(false) @boolean
|
||||
"throw" @exception
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"switch"
|
||||
"case"
|
||||
"default"
|
||||
] @conditional
|
||||
|
||||
[
|
||||
"for"
|
||||
"foreach"
|
||||
"while"
|
||||
"do"
|
||||
] @repeat
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
; Operators
|
||||
|
||||
(binary_expression
|
||||
(_)
|
||||
[
|
||||
"*"
|
||||
"/"
|
||||
|
|
@ -78,34 +106,27 @@
|
|||
"^="
|
||||
"??"
|
||||
] @operator
|
||||
(_)
|
||||
)
|
||||
|
||||
(unary_expression
|
||||
(_)?
|
||||
[
|
||||
"-"
|
||||
"!"
|
||||
"--"
|
||||
"++"
|
||||
] @operator
|
||||
(_)?
|
||||
)
|
||||
|
||||
(null) @keyword
|
||||
|
||||
; Methods
|
||||
|
||||
(function_definition
|
||||
(modifier)* @keyword
|
||||
type: (_) @type
|
||||
name: [
|
||||
(identifier) @method
|
||||
(camel_cased_identifier) @type
|
||||
(generic_identifier (_) @type)
|
||||
(namespaced_identifier
|
||||
left: (_)
|
||||
right: (_) @method .
|
||||
(_) @method .
|
||||
)
|
||||
]
|
||||
)
|
||||
|
|
@ -116,18 +137,11 @@
|
|||
(camel_cased_identifier) @type
|
||||
(generic_identifier (_) @type)
|
||||
(namespaced_identifier
|
||||
left: (_)
|
||||
right: (_) @method .
|
||||
(_) @method .
|
||||
)
|
||||
]
|
||||
(parameter_list)
|
||||
)
|
||||
|
||||
; Modifiers
|
||||
|
||||
(modifier) @keyword
|
||||
"var" @keyword
|
||||
|
||||
; Types
|
||||
|
||||
(primitive_type) @type
|
||||
|
|
@ -137,16 +151,6 @@
|
|||
"?" @symbol
|
||||
)
|
||||
|
||||
"typeof" @keyword
|
||||
|
||||
"is" @keyword
|
||||
|
||||
(is_type_expression
|
||||
(_)
|
||||
"is" @keyword
|
||||
(_) @type
|
||||
)
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @comment
|
||||
|
|
@ -155,28 +159,16 @@
|
|||
|
||||
(namespace
|
||||
"namespace" @include
|
||||
(camel_cased_identifier) @namespace
|
||||
(_) @namespace
|
||||
)
|
||||
|
||||
"global" @namespace
|
||||
"global::" @namespace
|
||||
|
||||
"using" @include
|
||||
|
||||
; declaration
|
||||
(declaration
|
||||
(_)*
|
||||
[
|
||||
(camel_cased_identifier) @type
|
||||
(_)
|
||||
]
|
||||
(_)*
|
||||
)
|
||||
|
||||
; Classes
|
||||
|
||||
(class_declaration
|
||||
(modifier) @keyword
|
||||
"class" @keyword
|
||||
[
|
||||
(camel_cased_identifier) @type
|
||||
(generic_identifier (_) @type )
|
||||
|
|
@ -184,37 +176,26 @@
|
|||
)
|
||||
|
||||
(class_constructor_definition
|
||||
(modifier)* @keyword
|
||||
[
|
||||
(identifier)
|
||||
(namespaced_identifier)
|
||||
(camel_cased_identifier)
|
||||
(_)
|
||||
(namespaced_identifier (_) @constructor .)
|
||||
] @constructor
|
||||
(_)*
|
||||
)
|
||||
|
||||
(class_destructor
|
||||
"~" @symbol
|
||||
(_) @constructor
|
||||
(_)*
|
||||
)
|
||||
|
||||
; Interfaces
|
||||
|
||||
(interface_declaration
|
||||
(modifier) @keyword
|
||||
"interface" @keyword
|
||||
[
|
||||
(camel_cased_identifier) @type
|
||||
(generic_identifier (_) @type )
|
||||
]
|
||||
)
|
||||
|
||||
; Class properties
|
||||
|
||||
(property_parameter) @keyword
|
||||
(this) @keyword
|
||||
|
||||
; Strings and escape sequences
|
||||
|
||||
(string_literal) @string
|
||||
|
|
@ -228,138 +209,57 @@
|
|||
|
||||
(string_template_expression) @variable
|
||||
|
||||
; Assignment and declaration
|
||||
; New instance from Object
|
||||
|
||||
(new_instance
|
||||
[
|
||||
(
|
||||
"new" @keyword
|
||||
(_)*
|
||||
)
|
||||
(
|
||||
(_)*
|
||||
".new" @keyword
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
; Parameters
|
||||
|
||||
(instanciation_parameter
|
||||
(modifier) @keyword
|
||||
".new" @keyword
|
||||
)
|
||||
|
||||
; GObject construct
|
||||
|
||||
"construct" @constructor
|
||||
|
||||
; Conditionals
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"switch"
|
||||
"case"
|
||||
"default"
|
||||
] @conditional
|
||||
|
||||
; Try statement
|
||||
|
||||
(try_statement
|
||||
"try" @keyword
|
||||
(block)
|
||||
"catch" @keyword
|
||||
exception: (parameter_list (declaration_parameter
|
||||
(_) @exception
|
||||
(_) @variable
|
||||
))
|
||||
(block)
|
||||
)
|
||||
|
||||
; Enum
|
||||
|
||||
"enum" @keyword
|
||||
(enum_declaration
|
||||
(camel_cased_identifier) @type
|
||||
(_)*
|
||||
)
|
||||
|
||||
; Loop
|
||||
|
||||
[
|
||||
"for"
|
||||
"foreach"
|
||||
"in"
|
||||
"while"
|
||||
"do"
|
||||
] @repeat
|
||||
|
||||
(foreach_statement
|
||||
(_)*
|
||||
loop_item: (identifier) @variable
|
||||
(_)*
|
||||
)
|
||||
|
||||
; Generics
|
||||
|
||||
(generic_identifier
|
||||
(camel_cased_identifier) @type
|
||||
)
|
||||
|
||||
; Closure
|
||||
|
||||
(closure
|
||||
"("
|
||||
(identifier)* @variable
|
||||
")"
|
||||
(_)*
|
||||
)
|
||||
|
||||
; Casting
|
||||
|
||||
(static_cast
|
||||
(_) @type
|
||||
type: (_) @type
|
||||
)
|
||||
|
||||
(dynamic_cast
|
||||
(_)
|
||||
"as" @keyword
|
||||
(_) @type
|
||||
)
|
||||
|
||||
; Throw error
|
||||
|
||||
"throws" @keyword
|
||||
"throw" @exception
|
||||
|
||||
; Ownership
|
||||
|
||||
(ownership_transfer
|
||||
"owned" @keyword
|
||||
(_)
|
||||
type: (_) @type
|
||||
)
|
||||
|
||||
; Regex
|
||||
|
||||
(regex_literal) @string.regex
|
||||
|
||||
; Contract programming
|
||||
|
||||
"requires" @keyword
|
||||
"ensures" @keyword
|
||||
|
||||
; Code attribute
|
||||
|
||||
(code_attribute
|
||||
"[" @attribute
|
||||
name: (camel_cased_identifier) @attribute
|
||||
(
|
||||
"(" @attribute
|
||||
(_)+
|
||||
")" @attribute
|
||||
)?
|
||||
"]" @attribute
|
||||
)
|
||||
param: (_) @attribute
|
||||
) @attribute
|
||||
|
||||
; Constant
|
||||
(uppercased_identifier) @constant
|
||||
|
|
@ -371,14 +271,11 @@
|
|||
(camel_cased_identifier) @namespace
|
||||
(identifier) @variable
|
||||
]
|
||||
(
|
||||
"."
|
||||
right: [
|
||||
(identifier) @parameter
|
||||
(camel_cased_identifier) @type
|
||||
(uppercased_identifier) @constant
|
||||
]
|
||||
)+
|
||||
right: [
|
||||
(identifier) @parameter
|
||||
(camel_cased_identifier) @type
|
||||
(uppercased_identifier) @constant
|
||||
]
|
||||
)
|
||||
|
||||
; Variable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue