mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Vala language support
This commit is contained in:
parent
3606f8efbb
commit
5fc4cb5d2d
4 changed files with 398 additions and 0 deletions
|
|
@ -249,6 +249,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [typescript](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka)
|
||||
- [x] [verilog](https://github.com/tree-sitter/tree-sitter-verilog) (experimental, maintained by @zegervdv)
|
||||
- [x] [vim](https://github.com/vigoux/tree-sitter-viml) (maintained by @vigoux)
|
||||
- [x] [vala](https://github.com/matbme/tree-sitter-vala) (maintained by @matbme)
|
||||
- [x] [vue](https://github.com/ikatyang/tree-sitter-vue) (maintained by @WhyNotHugo)
|
||||
- [x] [yaml](https://github.com/ikatyang/tree-sitter-yaml) (maintained by @stsewd)
|
||||
- [x] [yang](https://github.com/Hubro/tree-sitter-yang) (maintained by @Hubro)
|
||||
|
|
|
|||
1
ftdetect/vala.vim
Normal file
1
ftdetect/vala.vim
Normal file
|
|
@ -0,0 +1 @@
|
|||
au BufRead,BufNewFile *.vala set filetype=vala
|
||||
|
|
@ -912,6 +912,15 @@ list.norg = {
|
|||
maintainers = { "@JoeyGrajciar", "@vhyrro", "@mrossinek" },
|
||||
}
|
||||
|
||||
list.vala = {
|
||||
install_info = {
|
||||
url = "https://github.com/matbme/tree-sitter-vala",
|
||||
branch = "main",
|
||||
files = { "src/parser.c" },
|
||||
},
|
||||
maintainers = { "@matbme" },
|
||||
}
|
||||
|
||||
local M = {
|
||||
list = list,
|
||||
}
|
||||
|
|
|
|||
387
queries/vala/highlights.scm
Normal file
387
queries/vala/highlights.scm
Normal file
|
|
@ -0,0 +1,387 @@
|
|||
; Pointers
|
||||
|
||||
(address_of_identifier
|
||||
"&" @symbol
|
||||
(_)*
|
||||
)
|
||||
|
||||
(pointer_type
|
||||
(_)*
|
||||
"*" @symbol
|
||||
)
|
||||
|
||||
(indirection_identifier
|
||||
"*" @symbol
|
||||
(_)*
|
||||
)
|
||||
|
||||
"delete" @keyword
|
||||
|
||||
; Misc
|
||||
|
||||
(number) @number
|
||||
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
"("
|
||||
")"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
";"
|
||||
"."
|
||||
","
|
||||
"->"
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Keywords
|
||||
|
||||
"return" @keyword.return
|
||||
"yield" @keyword.return
|
||||
"break" @keyword.return
|
||||
|
||||
; Booleans
|
||||
|
||||
(true) @boolean
|
||||
(false) @boolean
|
||||
|
||||
; Operators
|
||||
|
||||
(binary_expression
|
||||
(_)
|
||||
[
|
||||
"*"
|
||||
"/"
|
||||
"+"
|
||||
"-"
|
||||
"%"
|
||||
"<"
|
||||
"<="
|
||||
">"
|
||||
">="
|
||||
"=="
|
||||
"!="
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"&&"
|
||||
"||"
|
||||
"&"
|
||||
"|"
|
||||
"^"
|
||||
"~"
|
||||
"|="
|
||||
"&="
|
||||
"^="
|
||||
"??"
|
||||
] @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 .
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
(function_call
|
||||
identifier: [
|
||||
(identifier) @method
|
||||
(camel_cased_identifier) @type
|
||||
(generic_identifier (_) @type)
|
||||
(namespaced_identifier
|
||||
left: (_)
|
||||
right: (_) @method .
|
||||
)
|
||||
]
|
||||
(parameter_list)
|
||||
)
|
||||
|
||||
; Modifiers
|
||||
|
||||
(modifier) @keyword
|
||||
"var" @keyword
|
||||
|
||||
; Types
|
||||
|
||||
(primitive_type) @type
|
||||
|
||||
(nullable_type
|
||||
(_) @type
|
||||
"?" @symbol
|
||||
)
|
||||
|
||||
"typeof" @keyword
|
||||
|
||||
"is" @keyword
|
||||
|
||||
(is_type_expression
|
||||
(_)
|
||||
"is" @keyword
|
||||
(_) @type
|
||||
)
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @comment
|
||||
|
||||
; Namespace
|
||||
|
||||
(namespace
|
||||
"namespace" @include
|
||||
(camel_cased_identifier) @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 )
|
||||
]
|
||||
)
|
||||
|
||||
(class_constructor_definition
|
||||
(modifier)* @keyword
|
||||
[
|
||||
(identifier)
|
||||
(namespaced_identifier)
|
||||
(camel_cased_identifier)
|
||||
] @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
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(string_template
|
||||
"@" @symbol
|
||||
) @string
|
||||
|
||||
(string_template_variable) @variable
|
||||
|
||||
(string_template_expression) @variable
|
||||
|
||||
; Assignment and declaration
|
||||
|
||||
(new_instance
|
||||
[
|
||||
(
|
||||
"new" @keyword
|
||||
(_)*
|
||||
)
|
||||
(
|
||||
(_)*
|
||||
".new" @keyword
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
; Parameters
|
||||
|
||||
(instanciation_parameter
|
||||
(modifier) @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
|
||||
)
|
||||
|
||||
(dynamic_cast
|
||||
(_)
|
||||
"as" @keyword
|
||||
(_) @type
|
||||
)
|
||||
|
||||
; Throw error
|
||||
|
||||
"throws" @keyword
|
||||
"throw" @exception
|
||||
|
||||
; Ownership
|
||||
|
||||
(ownership_transfer
|
||||
"owned" @keyword
|
||||
(_)
|
||||
)
|
||||
|
||||
; Regex
|
||||
|
||||
(regex_literal) @string.regex
|
||||
|
||||
; Contract programming
|
||||
|
||||
"requires" @keyword
|
||||
"ensures" @keyword
|
||||
|
||||
; Code attribute
|
||||
|
||||
(code_attribute
|
||||
"[" @attribute
|
||||
name: (camel_cased_identifier) @attribute
|
||||
(
|
||||
"(" @attribute
|
||||
(_)+
|
||||
")" @attribute
|
||||
)?
|
||||
"]" @attribute
|
||||
)
|
||||
|
||||
; Constant
|
||||
(uppercased_identifier) @constant
|
||||
|
||||
; Other
|
||||
|
||||
(namespaced_identifier
|
||||
left: [
|
||||
(camel_cased_identifier) @namespace
|
||||
(identifier) @variable
|
||||
]
|
||||
(
|
||||
"."
|
||||
right: [
|
||||
(identifier) @parameter
|
||||
(camel_cased_identifier) @type
|
||||
(uppercased_identifier) @constant
|
||||
]
|
||||
)+
|
||||
)
|
||||
|
||||
; Variable
|
||||
|
||||
(identifier) @variable
|
||||
(camel_cased_identifier) @variable
|
||||
Loading…
Add table
Add a link
Reference in a new issue