Simplify vala highlights.scm

This commit is contained in:
Mateus B. Melchiades 2022-01-29 11:18:26 -03:00 committed by Stephan Seitz
parent a162d42175
commit 3f046500ae

View file

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