mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-19 20:00:07 -04:00
feat!: switch upstream Zig parser
The new parser is faster, does not lag while editing, correctly parses the entire Zig code base, and is much easier to write queries for.
This commit is contained in:
parent
585860a186
commit
ba921c9aef
7 changed files with 217 additions and 163 deletions
|
|
@ -464,7 +464,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||||
- [x] [yang](https://github.com/Hubro/tree-sitter-yang) (maintained by @Hubro)
|
- [x] [yang](https://github.com/Hubro/tree-sitter-yang) (maintained by @Hubro)
|
||||||
- [x] [yuck](https://github.com/Philipp-M/tree-sitter-yuck) (maintained by @Philipp-M, @amaanq)
|
- [x] [yuck](https://github.com/Philipp-M/tree-sitter-yuck) (maintained by @Philipp-M, @amaanq)
|
||||||
- [x] [zathurarc](https://github.com/Freed-Wu/tree-sitter-zathurarc) (maintained by @Freed-Wu)
|
- [x] [zathurarc](https://github.com/Freed-Wu/tree-sitter-zathurarc) (maintained by @Freed-Wu)
|
||||||
- [x] [zig](https://github.com/maxxnino/tree-sitter-zig) (maintained by @maxxnino)
|
- [x] [zig](https://github.com/tree-sitter-grammars/tree-sitter-zig) (maintained by @amaanq)
|
||||||
<!--parserinfo-->
|
<!--parserinfo-->
|
||||||
|
|
||||||
For related information on the supported languages, including related plugins, see [this wiki page](https://github.com/nvim-treesitter/nvim-treesitter/wiki/Supported-Languages-Information).
|
For related information on the supported languages, including related plugins, see [this wiki page](https://github.com/nvim-treesitter/nvim-treesitter/wiki/Supported-Languages-Information).
|
||||||
|
|
|
||||||
|
|
@ -873,6 +873,6 @@
|
||||||
"revision": "0554b4a5d313244b7fc000cbb41c04afae4f4e31"
|
"revision": "0554b4a5d313244b7fc000cbb41c04afae4f4e31"
|
||||||
},
|
},
|
||||||
"zig": {
|
"zig": {
|
||||||
"revision": "2bac4cc6c697d46a193905fef6d003bfa0bfabfd"
|
"revision": "21e2218e0ec7f4e3c0640d16bf8c67e6f0a61e18"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2508,10 +2508,10 @@ list.zathurarc = {
|
||||||
|
|
||||||
list.zig = {
|
list.zig = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/maxxnino/tree-sitter-zig",
|
url = "https://github.com/tree-sitter-grammars/tree-sitter-zig",
|
||||||
files = { "src/parser.c" },
|
files = { "src/parser.c" },
|
||||||
},
|
},
|
||||||
maintainers = { "@maxxnino" },
|
maintainers = { "@amaanq" },
|
||||||
}
|
}
|
||||||
|
|
||||||
list.templ = {
|
list.templ = {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,23 @@
|
||||||
[
|
[
|
||||||
(Block)
|
(block)
|
||||||
(ContainerDecl)
|
(switch_expression)
|
||||||
(SwitchExpr)
|
(initializer_list)
|
||||||
(InitList)
|
(asm_expression)
|
||||||
(AsmExpr)
|
(multiline_string)
|
||||||
(ErrorSetDecl)
|
(if_statement)
|
||||||
(LINESTRING)
|
(while_statement)
|
||||||
[
|
(for_statement)
|
||||||
(IfPrefix)
|
(if_expression)
|
||||||
(WhilePrefix)
|
(else_clause)
|
||||||
(ForPrefix)
|
(for_expression)
|
||||||
]
|
(while_expression)
|
||||||
|
(if_type_expression)
|
||||||
|
(function_signature)
|
||||||
|
(parameters)
|
||||||
|
(call_expression)
|
||||||
|
(struct_declaration)
|
||||||
|
(opaque_declaration)
|
||||||
|
(enum_declaration)
|
||||||
|
(union_declaration)
|
||||||
|
(error_set_declaration)
|
||||||
] @fold
|
] @fold
|
||||||
|
|
|
||||||
|
|
@ -1,104 +1,116 @@
|
||||||
(line_comment) @comment @spell
|
; Variables
|
||||||
|
(identifier) @variable
|
||||||
|
|
||||||
|
; Parameters
|
||||||
|
(parameter
|
||||||
|
name: (identifier) @variable.parameter)
|
||||||
|
|
||||||
|
(payload
|
||||||
|
(identifier) @variable.parameter)
|
||||||
|
|
||||||
|
; Types
|
||||||
|
(parameter
|
||||||
|
type: (identifier) @type)
|
||||||
|
|
||||||
|
((identifier) @type
|
||||||
|
(#lua-match? @type "^[A-Z_][a-zA-Z0-9_]*"))
|
||||||
|
|
||||||
|
(variable_declaration
|
||||||
|
(identifier) @type
|
||||||
|
"="
|
||||||
|
[
|
||||||
|
(struct_declaration)
|
||||||
|
(enum_declaration)
|
||||||
|
(union_declaration)
|
||||||
|
(opaque_declaration)
|
||||||
|
])
|
||||||
|
|
||||||
[
|
[
|
||||||
(container_doc_comment)
|
(builtin_type)
|
||||||
(doc_comment)
|
"anyframe"
|
||||||
] @comment.documentation @spell
|
] @type.builtin
|
||||||
|
|
||||||
|
; Constants
|
||||||
|
((identifier) @constant
|
||||||
|
(#lua-match? @constant "^[A-Z][A-Z_0-9]+$"))
|
||||||
|
|
||||||
[
|
[
|
||||||
variable: (IDENTIFIER)
|
"null"
|
||||||
variable_type_function: (IDENTIFIER)
|
"unreachable"
|
||||||
] @variable
|
"undefined"
|
||||||
|
] @constant.builtin
|
||||||
|
|
||||||
parameter: (IDENTIFIER) @variable.parameter
|
(field_expression
|
||||||
|
.
|
||||||
|
member: (identifier) @constant)
|
||||||
|
|
||||||
|
(enum_declaration
|
||||||
|
(container_field
|
||||||
|
type: (identifier) @constant))
|
||||||
|
|
||||||
|
; Labels
|
||||||
|
(block_label
|
||||||
|
(identifier) @label)
|
||||||
|
|
||||||
|
(break_label
|
||||||
|
(identifier) @label)
|
||||||
|
|
||||||
|
; Fields
|
||||||
|
(field_initializer
|
||||||
|
.
|
||||||
|
(identifier) @variable.member)
|
||||||
|
|
||||||
|
(field_expression
|
||||||
|
(_)
|
||||||
|
member: (identifier) @variable.member)
|
||||||
|
|
||||||
|
(container_field
|
||||||
|
name: (identifier) @variable.member)
|
||||||
|
|
||||||
|
(initializer_list
|
||||||
|
(assignment_expression
|
||||||
|
left: (field_expression
|
||||||
|
.
|
||||||
|
member: (identifier) @variable.member)))
|
||||||
|
|
||||||
|
; Functions
|
||||||
|
(builtin_identifier) @function.builtin
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @function.call)
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (field_expression
|
||||||
|
member: (identifier) @function.call))
|
||||||
|
|
||||||
|
(function_declaration
|
||||||
|
name: (identifier) @function)
|
||||||
|
|
||||||
|
; Modules
|
||||||
|
(variable_declaration
|
||||||
|
(identifier) @module
|
||||||
|
(builtin_function
|
||||||
|
(builtin_identifier) @keyword.import
|
||||||
|
(#any-of? @keyword.import "@import" "@cImport")))
|
||||||
|
|
||||||
|
; Builtins
|
||||||
[
|
[
|
||||||
field_member: (IDENTIFIER)
|
"c"
|
||||||
field_access: (IDENTIFIER)
|
"..."
|
||||||
] @variable.member
|
] @variable.builtin
|
||||||
|
|
||||||
; assume TitleCase is a type
|
((identifier) @variable.builtin
|
||||||
([
|
|
||||||
variable_type_function: (IDENTIFIER)
|
|
||||||
field_access: (IDENTIFIER)
|
|
||||||
parameter: (IDENTIFIER)
|
|
||||||
] @type
|
|
||||||
(#lua-match? @type "^%u([%l]+[%u%l%d]*)*$"))
|
|
||||||
|
|
||||||
; assume camelCase is a function
|
|
||||||
([
|
|
||||||
variable_type_function: (IDENTIFIER)
|
|
||||||
field_access: (IDENTIFIER)
|
|
||||||
parameter: (IDENTIFIER)
|
|
||||||
] @function
|
|
||||||
(#lua-match? @function "^%l+([%u][%l%d]*)+$"))
|
|
||||||
|
|
||||||
; assume all CAPS_1 is a constant
|
|
||||||
([
|
|
||||||
variable_type_function: (IDENTIFIER)
|
|
||||||
field_access: (IDENTIFIER)
|
|
||||||
] @constant
|
|
||||||
(#lua-match? @constant "^%u[%u%d_]+$"))
|
|
||||||
|
|
||||||
function: (IDENTIFIER) @function
|
|
||||||
|
|
||||||
function_call: (IDENTIFIER) @function.call
|
|
||||||
|
|
||||||
exception: "!" @keyword.exception
|
|
||||||
|
|
||||||
((IDENTIFIER) @variable.builtin
|
|
||||||
(#eq? @variable.builtin "_"))
|
(#eq? @variable.builtin "_"))
|
||||||
|
|
||||||
(PtrTypeStart
|
(calling_convention
|
||||||
"c" @variable.builtin)
|
(identifier) @variable.builtin)
|
||||||
|
|
||||||
(ContainerDecl
|
|
||||||
(ContainerDeclType
|
|
||||||
"enum")
|
|
||||||
(ContainerField
|
|
||||||
(ErrorUnionExpr
|
|
||||||
(SuffixExpr
|
|
||||||
(IDENTIFIER) @constant))))
|
|
||||||
|
|
||||||
field_constant: (IDENTIFIER) @constant
|
|
||||||
|
|
||||||
(BUILTINIDENTIFIER) @function.builtin
|
|
||||||
|
|
||||||
((BUILTINIDENTIFIER) @keyword.import
|
|
||||||
(#any-of? @keyword.import "@import" "@cImport"))
|
|
||||||
|
|
||||||
(INTEGER) @number
|
|
||||||
|
|
||||||
(FLOAT) @number.float
|
|
||||||
|
|
||||||
[
|
|
||||||
"true"
|
|
||||||
"false"
|
|
||||||
] @boolean
|
|
||||||
|
|
||||||
[
|
|
||||||
(LINESTRING)
|
|
||||||
(STRINGLITERALSINGLE)
|
|
||||||
] @string @spell
|
|
||||||
|
|
||||||
(CHAR_LITERAL) @character
|
|
||||||
|
|
||||||
(EscapeSequence) @string.escape
|
|
||||||
|
|
||||||
(FormatSequence) @string.special
|
|
||||||
|
|
||||||
(BreakLabel
|
|
||||||
(IDENTIFIER) @label)
|
|
||||||
|
|
||||||
(BlockLabel
|
|
||||||
(IDENTIFIER) @label)
|
|
||||||
|
|
||||||
|
; Keywords
|
||||||
[
|
[
|
||||||
"asm"
|
"asm"
|
||||||
"defer"
|
"defer"
|
||||||
"errdefer"
|
"errdefer"
|
||||||
"test"
|
"test"
|
||||||
"opaque"
|
|
||||||
"error"
|
"error"
|
||||||
"const"
|
"const"
|
||||||
"var"
|
"var"
|
||||||
|
|
@ -108,6 +120,7 @@ field_constant: (IDENTIFIER) @constant
|
||||||
"struct"
|
"struct"
|
||||||
"union"
|
"union"
|
||||||
"enum"
|
"enum"
|
||||||
|
"opaque"
|
||||||
] @keyword.type
|
] @keyword.type
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
@ -151,11 +164,6 @@ field_constant: (IDENTIFIER) @constant
|
||||||
"catch"
|
"catch"
|
||||||
] @keyword.exception
|
] @keyword.exception
|
||||||
|
|
||||||
[
|
|
||||||
"anytype"
|
|
||||||
(BuildinTypeExpr)
|
|
||||||
] @type.builtin
|
|
||||||
|
|
||||||
[
|
[
|
||||||
"volatile"
|
"volatile"
|
||||||
"allowzero"
|
"allowzero"
|
||||||
|
|
@ -168,50 +176,85 @@ field_constant: (IDENTIFIER) @constant
|
||||||
"inline"
|
"inline"
|
||||||
"noinline"
|
"noinline"
|
||||||
"extern"
|
"extern"
|
||||||
] @keyword.modifier
|
|
||||||
|
|
||||||
[
|
|
||||||
"comptime"
|
"comptime"
|
||||||
"packed"
|
"packed"
|
||||||
"threadlocal"
|
"threadlocal"
|
||||||
] @attribute
|
] @keyword.modifier
|
||||||
|
|
||||||
|
; Operator
|
||||||
[
|
[
|
||||||
"null"
|
|
||||||
"unreachable"
|
|
||||||
"undefined"
|
|
||||||
] @constant.builtin
|
|
||||||
|
|
||||||
[
|
|
||||||
(CompareOp)
|
|
||||||
(BitwiseOp)
|
|
||||||
(BitShiftOp)
|
|
||||||
(AdditionOp)
|
|
||||||
(AssignOp)
|
|
||||||
(MultiplyOp)
|
|
||||||
(PrefixOp)
|
|
||||||
"="
|
"="
|
||||||
|
"*="
|
||||||
|
"*%="
|
||||||
|
"*|="
|
||||||
|
"/="
|
||||||
|
"%="
|
||||||
|
"+="
|
||||||
|
"+%="
|
||||||
|
"+|="
|
||||||
|
"-="
|
||||||
|
"-%="
|
||||||
|
"-|="
|
||||||
|
"<<="
|
||||||
|
"<<|="
|
||||||
|
">>="
|
||||||
|
"&="
|
||||||
|
"^="
|
||||||
|
"|="
|
||||||
|
"!"
|
||||||
|
"~"
|
||||||
|
"-"
|
||||||
|
"-%"
|
||||||
|
"&"
|
||||||
|
"=="
|
||||||
|
"!="
|
||||||
|
">"
|
||||||
|
">="
|
||||||
|
"<="
|
||||||
|
"<"
|
||||||
|
"&"
|
||||||
|
"^"
|
||||||
|
"|"
|
||||||
|
"<<"
|
||||||
|
">>"
|
||||||
|
"<<|"
|
||||||
|
"+"
|
||||||
|
"++"
|
||||||
|
"+%"
|
||||||
|
"-%"
|
||||||
|
"+|"
|
||||||
|
"-|"
|
||||||
"*"
|
"*"
|
||||||
|
"/"
|
||||||
|
"%"
|
||||||
"**"
|
"**"
|
||||||
"->"
|
"*%"
|
||||||
".?"
|
"*|"
|
||||||
|
"||"
|
||||||
".*"
|
".*"
|
||||||
|
".?"
|
||||||
"?"
|
"?"
|
||||||
|
".."
|
||||||
] @operator
|
] @operator
|
||||||
|
|
||||||
[
|
; Literals
|
||||||
";"
|
(character) @character
|
||||||
"."
|
|
||||||
","
|
|
||||||
":"
|
|
||||||
"=>"
|
|
||||||
] @punctuation.delimiter
|
|
||||||
|
|
||||||
[
|
([
|
||||||
".."
|
(string)
|
||||||
"..."
|
(multiline_string)
|
||||||
] @punctuation.special
|
] @string
|
||||||
|
(#set! "priority" 95))
|
||||||
|
|
||||||
|
(integer) @number
|
||||||
|
|
||||||
|
(float) @number.float
|
||||||
|
|
||||||
|
(boolean) @boolean
|
||||||
|
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
|
||||||
|
; Punctuation
|
||||||
[
|
[
|
||||||
"["
|
"["
|
||||||
"]"
|
"]"
|
||||||
|
|
@ -221,19 +264,20 @@ field_constant: (IDENTIFIER) @constant
|
||||||
"}"
|
"}"
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
|
||||||
(Payload
|
[
|
||||||
|
";"
|
||||||
|
"."
|
||||||
|
","
|
||||||
|
":"
|
||||||
|
"=>"
|
||||||
|
"->"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
(payload
|
||||||
"|" @punctuation.bracket)
|
"|" @punctuation.bracket)
|
||||||
|
|
||||||
(PtrPayload
|
; Comments
|
||||||
"|" @punctuation.bracket)
|
(comment) @comment @spell
|
||||||
|
|
||||||
(PtrIndexPayload
|
((comment) @comment.documentation
|
||||||
"|" @punctuation.bracket)
|
(#lua-match? @comment.documentation "^//!"))
|
||||||
|
|
||||||
(PtrListPayload
|
|
||||||
"|" @punctuation.bracket)
|
|
||||||
|
|
||||||
(ParamType
|
|
||||||
(ErrorUnionExpr
|
|
||||||
(SuffixExpr
|
|
||||||
variable_type_function: (IDENTIFIER) @type)))
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
[
|
[
|
||||||
(Block)
|
(block)
|
||||||
(ContainerDecl)
|
(switch_expression)
|
||||||
(SwitchExpr)
|
(initializer_list)
|
||||||
(InitList)
|
|
||||||
] @indent.begin
|
] @indent.begin
|
||||||
|
|
||||||
(Block
|
(block
|
||||||
"}" @indent.end)
|
"}" @indent.end)
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
@ -18,8 +17,6 @@
|
||||||
] @indent.branch
|
] @indent.branch
|
||||||
|
|
||||||
[
|
[
|
||||||
(line_comment)
|
(comment)
|
||||||
(container_doc_comment)
|
(multiline_string)
|
||||||
(doc_comment)
|
|
||||||
(LINESTRING)
|
|
||||||
] @indent.ignore
|
] @indent.ignore
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
([
|
((comment) @injection.content
|
||||||
(container_doc_comment)
|
|
||||||
(doc_comment)
|
|
||||||
(line_comment)
|
|
||||||
] @injection.content
|
|
||||||
(#set! injection.language "comment"))
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
; TODO: add when asm is added
|
||||||
|
; (asm_output_item (string) @injection.content
|
||||||
|
; (#set! injection.language "asm"))
|
||||||
|
; (asm_input_item (string) @injection.content
|
||||||
|
; (#set! injection.language "asm"))
|
||||||
|
; (asm_clobbers (string) @injection.content
|
||||||
|
; (#set! injection.language "asm"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue