mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-13 17:00:09 -04:00
feat(vala)!: switch to @vala-lang parser
This commit is contained in:
parent
32e033a8f5
commit
f3c309db4e
3 changed files with 221 additions and 273 deletions
|
|
@ -339,7 +339,7 @@
|
||||||
"revision": "7aea71859e9405d4646bcfc1ea1dbc0ebdcffc21"
|
"revision": "7aea71859e9405d4646bcfc1ea1dbc0ebdcffc21"
|
||||||
},
|
},
|
||||||
"vala": {
|
"vala": {
|
||||||
"revision": "31a08784cc74b61cb10c5d8314cf8a8aa98aa9a8"
|
"revision": "8f690bfa639f2b83d1fb938ed3dd98a7ba453e8b"
|
||||||
},
|
},
|
||||||
"verilog": {
|
"verilog": {
|
||||||
"revision": "8f6b1f357d1231c420404b5f7a368a73c25adfa2"
|
"revision": "8f6b1f357d1231c420404b5f7a368a73c25adfa2"
|
||||||
|
|
|
||||||
|
|
@ -1031,11 +1031,11 @@ list.norg = {
|
||||||
|
|
||||||
list.vala = {
|
list.vala = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/matbme/tree-sitter-vala",
|
url = "https://github.com/vala-lang/tree-sitter-vala",
|
||||||
branch = "main",
|
branch = "master",
|
||||||
files = { "src/parser.c", "src/scanner.cc" },
|
files = { "src/parser.c" },
|
||||||
},
|
},
|
||||||
maintainers = { "@matbme" },
|
maintainers = { "@Prince781", "@vala-lang" },
|
||||||
}
|
}
|
||||||
|
|
||||||
list.lalrpop = {
|
list.lalrpop = {
|
||||||
|
|
|
||||||
|
|
@ -1,297 +1,245 @@
|
||||||
; Identifiers
|
; highlights.scm
|
||||||
|
|
||||||
((identifier) @constant (#match? @constant "^[A-Z][A-Z\\d_]+$"))
|
; higlight comments and symbols
|
||||||
|
(comment) @comment
|
||||||
|
(symbol) @symbol
|
||||||
|
(member_access_expression (_) (identifier) @symbol)
|
||||||
|
|
||||||
(namespaced_identifier
|
; highlight constants
|
||||||
left: [
|
(
|
||||||
; Lowercased names in lhs typically are variables, while camel cased are namespaces
|
(member_access_expression (identifier) @constant)
|
||||||
; ((identifier) @namespace (#match? @namespace "^[A-Z]+[a-z]+$"))
|
(#match? @constant "^[A-Z][A-Z_0-9]*$")
|
||||||
((identifier) @variable (#match? @variable "^[a-z]"))
|
|
||||||
(_)
|
|
||||||
]
|
|
||||||
right: [
|
|
||||||
; Lowercased are variables, camel cased are types
|
|
||||||
; ((identifier) @parameter (#match? @parameter "^[a-z]"))
|
|
||||||
((identifier) @type (#match? @type "^[A-Z]+[a-z]+$"))
|
|
||||||
(_)
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
((identifier) @constructor (#match? @constructor "^[A-Z]*[a-z]+"))
|
(
|
||||||
|
(member_access_expression (member_access_expression) @include (identifier) @constant)
|
||||||
|
(#match? @constant "^[A-Z][A-Z_0-9]*$")
|
||||||
|
)
|
||||||
|
|
||||||
; Pointers
|
; highlight types and probable types
|
||||||
|
(type (symbol (_)? @namespace (identifier) @type))
|
||||||
|
(
|
||||||
|
(member_access_expression . (identifier) @type)
|
||||||
|
(#match? @type "^[A-Z][A-Za-z_0-9]{2,}$")
|
||||||
|
)
|
||||||
|
|
||||||
(address_of_identifier "&" @symbol)
|
; highlight creation methods in object creation expressions
|
||||||
(pointer_type "*" @symbol)
|
(
|
||||||
(indirection_identifier "*" @symbol)
|
(object_creation_expression (type (symbol (symbol (symbol)? @include (identifier) @type) (identifier) @constructor)))
|
||||||
|
(#match? @constructor "^[a-z][a-z_0-9]*$")
|
||||||
|
)
|
||||||
|
|
||||||
; Misc
|
(unqualified_type (symbol . (identifier) @type))
|
||||||
|
(unqualified_type (symbol (symbol) @namespace (identifier) @type))
|
||||||
(number) @number
|
|
||||||
|
|
||||||
|
(attribute) @attribute
|
||||||
|
(namespace_declaration (symbol) @namespace)
|
||||||
|
(method_declaration (symbol (symbol) @type (identifier) @function))
|
||||||
|
(method_declaration (symbol (identifier) @function))
|
||||||
|
(local_declaration (assignment (identifier) @variable))
|
||||||
|
(local_function_declaration (identifier) @function)
|
||||||
|
(destructor_declaration (identifier) @function)
|
||||||
|
(creation_method_declaration (symbol (symbol) @type (identifier) @constructor))
|
||||||
|
(creation_method_declaration (symbol (identifier) @constructor))
|
||||||
|
(constructor_declaration (_)? "construct" @keyword.function)
|
||||||
|
(enum_declaration (symbol) @type)
|
||||||
|
(enum_value (identifier) @constant)
|
||||||
|
(errordomain_declaration (symbol) @type)
|
||||||
|
(errorcode (identifier) @constant)
|
||||||
|
(constant_declaration (identifier) @constant)
|
||||||
|
(method_call_expression (member_access_expression (identifier) @function))
|
||||||
|
; highlight macros
|
||||||
|
(
|
||||||
|
(method_call_expression (member_access_expression (identifier) @function.macro))
|
||||||
|
(#match? @function.macro "^assert[A-Za-z_0-9]*$" "error" "info" "debug" "print" "warning" "warning_once")
|
||||||
|
)
|
||||||
|
(lambda_expression (identifier) @parameter)
|
||||||
|
(parameter (identifier) @parameter)
|
||||||
|
(property_declaration (symbol (identifier) @property))
|
||||||
|
(field_declaration (identifier) @field)
|
||||||
[
|
[
|
||||||
"{"
|
(this_access)
|
||||||
"}"
|
(base_access)
|
||||||
"("
|
(value_access)
|
||||||
")"
|
] @constant.builtin
|
||||||
"["
|
(boolean) @boolean
|
||||||
"]"
|
(character) @character
|
||||||
] @punctuation.bracket
|
(escape_sequence) @character.special
|
||||||
|
(integer) @number
|
||||||
[
|
|
||||||
";"
|
|
||||||
":"
|
|
||||||
"."
|
|
||||||
","
|
|
||||||
"->"
|
|
||||||
] @punctuation.delimiter
|
|
||||||
|
|
||||||
; Reserved keywords
|
|
||||||
|
|
||||||
[
|
|
||||||
"return"
|
|
||||||
"yield"
|
|
||||||
"break"
|
|
||||||
] @keyword.return
|
|
||||||
|
|
||||||
|
|
||||||
(null) @constant.builtin
|
(null) @constant.builtin
|
||||||
|
(real) @float
|
||||||
|
(regex) @string.regex
|
||||||
|
(string) @string
|
||||||
|
(string_formatter) @string.special
|
||||||
|
(template_string) @string
|
||||||
|
(template_string_expression) @string.special
|
||||||
|
(verbatim_string) @string
|
||||||
|
[
|
||||||
|
"var"
|
||||||
|
"void"
|
||||||
|
] @type.builtin
|
||||||
|
|
||||||
|
(if_directive
|
||||||
|
expression: (_) @preproc
|
||||||
|
) @keyword
|
||||||
|
(elif_directive
|
||||||
|
expression: (_) @preproc
|
||||||
|
) @keyword
|
||||||
|
(else_directive) @keyword
|
||||||
|
(endif_directive) @keyword
|
||||||
|
|
||||||
[
|
[
|
||||||
"typeof"
|
"abstract"
|
||||||
"is"
|
"async"
|
||||||
] @keyword.operator
|
"class"
|
||||||
|
"construct"
|
||||||
[
|
"continue"
|
||||||
(modifier)
|
"default"
|
||||||
"var"
|
"delegate"
|
||||||
"class"
|
"enum"
|
||||||
"interface"
|
"errordomain"
|
||||||
(property_parameter)
|
"get"
|
||||||
(this)
|
"inline"
|
||||||
"enum"
|
"interface"
|
||||||
"new"
|
"namespace"
|
||||||
"in"
|
"new"
|
||||||
"as"
|
"out"
|
||||||
"try"
|
"override"
|
||||||
"catch"
|
"partial"
|
||||||
"requires"
|
"ref"
|
||||||
"ensures"
|
"set"
|
||||||
"owned"
|
"signal"
|
||||||
"throws"
|
"struct"
|
||||||
"delete"
|
"virtual"
|
||||||
"#if"
|
"with"
|
||||||
"#elif"
|
|
||||||
(preproc_else)
|
|
||||||
(preproc_endif)
|
|
||||||
] @keyword
|
] @keyword
|
||||||
|
|
||||||
"throw" @exception
|
[
|
||||||
|
"const"
|
||||||
|
"dynamic"
|
||||||
|
"owned"
|
||||||
|
"weak"
|
||||||
|
"unowned"
|
||||||
|
] @type.qualifier
|
||||||
|
|
||||||
[
|
[
|
||||||
"if"
|
"case"
|
||||||
"else"
|
"else"
|
||||||
"switch"
|
"if"
|
||||||
"case"
|
"switch"
|
||||||
"default"
|
|
||||||
] @conditional
|
] @conditional
|
||||||
|
|
||||||
|
; specially highlight break statements in switch sections
|
||||||
|
(switch_section (break_statement "break" @conditional))
|
||||||
|
|
||||||
[
|
[
|
||||||
|
"extern"
|
||||||
|
"internal"
|
||||||
|
"private"
|
||||||
|
"protected"
|
||||||
|
"public"
|
||||||
|
"static"
|
||||||
|
] @storageclass
|
||||||
|
|
||||||
|
[
|
||||||
|
"and"
|
||||||
|
"as"
|
||||||
|
"delete"
|
||||||
|
"in"
|
||||||
|
"is"
|
||||||
|
"lock"
|
||||||
|
"not"
|
||||||
|
"or"
|
||||||
|
"sizeof"
|
||||||
|
"typeof"
|
||||||
|
] @keyword.operator
|
||||||
|
|
||||||
|
"using" @include
|
||||||
|
(using_directive (symbol) @namespace)
|
||||||
|
|
||||||
|
(symbol "global::" @namespace)
|
||||||
|
|
||||||
|
(array_creation_expression "new" @keyword.operator)
|
||||||
|
(object_creation_expression "new" @keyword.operator)
|
||||||
|
(argument "out" @keyword.operator)
|
||||||
|
(argument "ref" @keyword.operator)
|
||||||
|
|
||||||
|
[
|
||||||
|
"break"
|
||||||
|
"continue"
|
||||||
|
"do"
|
||||||
"for"
|
"for"
|
||||||
"foreach"
|
"foreach"
|
||||||
"while"
|
"while"
|
||||||
"do"
|
|
||||||
] @repeat
|
] @repeat
|
||||||
|
|
||||||
[
|
[
|
||||||
(true)
|
"catch"
|
||||||
(false)
|
"finally"
|
||||||
] @boolean
|
"throw"
|
||||||
|
"throws"
|
||||||
|
"try"
|
||||||
|
] @exception
|
||||||
|
|
||||||
; Operators
|
[
|
||||||
|
"return"
|
||||||
|
"yield"
|
||||||
|
] @keyword.return
|
||||||
|
|
||||||
(binary_expression
|
[
|
||||||
[
|
"="
|
||||||
"*"
|
"=="
|
||||||
"/"
|
"+"
|
||||||
"+"
|
"+="
|
||||||
"-"
|
"-"
|
||||||
"%"
|
"-="
|
||||||
"<"
|
"++"
|
||||||
"<="
|
"--"
|
||||||
">"
|
"|"
|
||||||
">="
|
"|="
|
||||||
"=="
|
"&"
|
||||||
"!="
|
"&="
|
||||||
"+="
|
"^"
|
||||||
"-="
|
"^="
|
||||||
"*="
|
"/"
|
||||||
"/="
|
"/="
|
||||||
"%="
|
"*"
|
||||||
"&&"
|
"*="
|
||||||
"||"
|
"%"
|
||||||
"&"
|
"%="
|
||||||
"|"
|
"<<"
|
||||||
"^"
|
"<<="
|
||||||
"~"
|
">>"
|
||||||
"|="
|
">>="
|
||||||
"&="
|
"."
|
||||||
"^="
|
"?."
|
||||||
"??"
|
"->"
|
||||||
"="
|
"!"
|
||||||
] @operator
|
"!="
|
||||||
)
|
"~"
|
||||||
|
"??"
|
||||||
|
"?"
|
||||||
|
":"
|
||||||
|
"<"
|
||||||
|
"<="
|
||||||
|
">"
|
||||||
|
">="
|
||||||
|
"||"
|
||||||
|
"&&"
|
||||||
|
"=>"
|
||||||
|
] @operator
|
||||||
|
|
||||||
(unary_expression
|
[
|
||||||
[
|
","
|
||||||
"-"
|
";"
|
||||||
"!"
|
] @punctuation.delimiter
|
||||||
"--"
|
|
||||||
"++"
|
|
||||||
] @operator
|
|
||||||
)
|
|
||||||
|
|
||||||
; Declaration
|
[
|
||||||
|
"$("
|
||||||
(declaration
|
"("
|
||||||
type_name: (_) @type
|
")"
|
||||||
)
|
"{"
|
||||||
|
"}"
|
||||||
; Methods
|
"["
|
||||||
|
"]"
|
||||||
(function_definition
|
] @punctuation.bracket
|
||||||
type: (_) @type
|
|
||||||
name: [
|
|
||||||
(identifier) @method
|
|
||||||
(generic_identifier (_) @type)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
(function_call
|
|
||||||
identifier: [
|
|
||||||
(identifier) @method
|
|
||||||
(generic_identifier (_) @type)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
(member_function
|
|
||||||
identifier: [
|
|
||||||
(identifier) @method
|
|
||||||
(generic_identifier (_) @type)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
; Types
|
|
||||||
|
|
||||||
(primitive_type) @type
|
|
||||||
|
|
||||||
(nullable_type
|
|
||||||
(_) @type
|
|
||||||
"?" @symbol
|
|
||||||
)
|
|
||||||
|
|
||||||
; Comments
|
|
||||||
|
|
||||||
(comment) @comment
|
|
||||||
|
|
||||||
; Namespace
|
|
||||||
|
|
||||||
(namespace
|
|
||||||
"namespace" @include
|
|
||||||
(_) @namespace
|
|
||||||
)
|
|
||||||
|
|
||||||
"global::" @namespace
|
|
||||||
|
|
||||||
(using
|
|
||||||
"using" @include
|
|
||||||
(_) @namespace
|
|
||||||
)
|
|
||||||
|
|
||||||
; Classes
|
|
||||||
|
|
||||||
(class_declaration) @type
|
|
||||||
|
|
||||||
(class_constructor_definition
|
|
||||||
name: [
|
|
||||||
(_)
|
|
||||||
(namespaced_identifier (_) @constructor .)
|
|
||||||
] @constructor
|
|
||||||
)
|
|
||||||
|
|
||||||
(class_destructor
|
|
||||||
"~" @symbol
|
|
||||||
(_) @constructor
|
|
||||||
)
|
|
||||||
|
|
||||||
; Interfaces
|
|
||||||
|
|
||||||
(interface_declaration) @type
|
|
||||||
|
|
||||||
; Strings and escape sequences
|
|
||||||
|
|
||||||
(string_literal) @string
|
|
||||||
(verbatim) @string
|
|
||||||
(escape_sequence) @string.escape
|
|
||||||
|
|
||||||
(string_template
|
|
||||||
"@" @symbol
|
|
||||||
) @string
|
|
||||||
|
|
||||||
(string_template_variable) @variable
|
|
||||||
|
|
||||||
(string_template_expression) @variable
|
|
||||||
|
|
||||||
; New instance from Object
|
|
||||||
|
|
||||||
(new_instance
|
|
||||||
"new" @keyword
|
|
||||||
)
|
|
||||||
|
|
||||||
; GObject construct
|
|
||||||
|
|
||||||
(gobject_construct
|
|
||||||
"construct" @keyword
|
|
||||||
)
|
|
||||||
|
|
||||||
; Try statement
|
|
||||||
|
|
||||||
(try_statement
|
|
||||||
exception: (parameter_list (declaration_parameter
|
|
||||||
(_) @exception
|
|
||||||
(_) @variable
|
|
||||||
))
|
|
||||||
)
|
|
||||||
|
|
||||||
; Enum
|
|
||||||
|
|
||||||
(enum_declaration
|
|
||||||
name: (identifier) @type
|
|
||||||
)
|
|
||||||
|
|
||||||
; Loop
|
|
||||||
|
|
||||||
(foreach_statement
|
|
||||||
loop_item: (identifier) @variable
|
|
||||||
)
|
|
||||||
|
|
||||||
; Casting
|
|
||||||
|
|
||||||
(static_cast
|
|
||||||
type: (_) @type
|
|
||||||
)
|
|
||||||
|
|
||||||
(dynamic_cast
|
|
||||||
type: (_) @type
|
|
||||||
)
|
|
||||||
|
|
||||||
; Regex
|
|
||||||
|
|
||||||
(regex_literal) @string.regex
|
|
||||||
|
|
||||||
; Code attribute
|
|
||||||
|
|
||||||
(code_attribute
|
|
||||||
name: (identifier) @attribute
|
|
||||||
param: (_) @attribute
|
|
||||||
) @attribute
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue