Update to more up-to-date zig tree-sitter repo

The previous tree-sitter repo seems to be unmaintained.

Switch to a more maintained tree-sitter repo.

I also fixed the queries: precedences, some helix captures, ...
pull/11980/head
Khang Nguyen Duy 4 weeks ago
parent 855a43a266
commit 75debfeb3e

@ -1396,7 +1396,7 @@ args = { console = "internalConsole", attachCommands = [ "platform select remote
[[grammar]] [[grammar]]
name = "zig" name = "zig"
source = { git = "https://github.com/maxxnino/tree-sitter-zig", rev = "0d08703e4c3f426ec61695d7617415fff97029bd" } source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-zig", rev = "eb7d58c2dc4fbeea4745019dee8df013034ae66b" }
[[language]] [[language]]
name = "prolog" name = "prolog"

@ -1,231 +1,294 @@
[ ; Comments
(container_doc_comment)
(doc_comment)
] @comment.documentation
[ ((comment) @comment.block.documentation
(line_comment) (#lua-match? @comment.block.documentation "^//!"))
] @comment.line
;; assume TitleCase is a type (comment) @comment.line
(
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
parameter: (IDENTIFIER)
] @type
(#match? @type "^[A-Z]([a-z]+[A-Za-z0-9]*)+$")
)
;; assume camelCase is a function
(
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
parameter: (IDENTIFIER)
] @function
(#match? @function "^[a-z]+([A-Z][a-z0-9]*)+$")
)
;; assume all CAPS_1 is a constant
(
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
] @constant
(#match? @constant "^[A-Z][A-Z_0-9]+$")
)
;; _ ; Punctuation
(
(IDENTIFIER) @variable.builtin
(#eq? @variable.builtin "_")
)
;; C Pointers [*c]T [
(PtrTypeStart "c" @variable.builtin) "["
"]"
"("
")"
"{"
"}"
] @punctuation.bracket
[ [
variable: (IDENTIFIER) ";"
variable_type_function: (IDENTIFIER) "."
] @variable ","
":"
"=>"
"->"
] @punctuation.delimiter
parameter: (IDENTIFIER) @variable.parameter (payload "|" @punctuation.bracket)
[ ; Literals
field_member: (IDENTIFIER)
field_access: (IDENTIFIER)
] @variable.other.member
[ (character) @constant.character
function_call: (IDENTIFIER)
function: (IDENTIFIER)
] @function
exception: "!" @keyword.control.exception ([
(string)
(multiline_string)
] @string
(#set! "priority" 95))
field_constant: (IDENTIFIER) @constant (integer) @constant.numeric.integer
(BUILTINIDENTIFIER) @function.builtin (float) @constant.numeric.float
((BUILTINIDENTIFIER) @keyword.control.import (boolean) @constant.builtin.boolean
(#any-of? @keyword.control.import "@import" "@cImport"))
(INTEGER) @constant.numeric.integer (escape_sequence) @constant.character.escape
(FLOAT) @constant.numeric.float ; Operator
[ [
(LINESTRING) "="
(STRINGLITERALSINGLE) "*="
] @string "*%="
"*|="
"/="
"%="
"+="
"+%="
"+|="
"-="
"-%="
"-|="
"<<="
"<<|="
">>="
"&="
"^="
"|="
"!"
"~"
"-"
"-%"
"&"
"=="
"!="
">"
">="
"<="
"<"
"&"
"^"
"|"
"<<"
">>"
"<<|"
"+"
"++"
"+%"
"-%"
"+|"
"-|"
"*"
"/"
"%"
"**"
"*%"
"*|"
"||"
".*"
".?"
"?"
".."
] @operator
(CHAR_LITERAL) @constant.character ; Keywords
(EscapeSequence) @constant.character.escape
(FormatSequence) @string.special
[ [
"anytype" "asm"
"anyframe" "test"
(BuildinTypeExpr) ] @keyword
] @type.builtin
[
"error"
"const"
"var"
"struct"
"union"
"enum"
"opaque"
] @keyword.storage.type
; todo: keyword.coroutine
[
"async"
"await"
"suspend"
"nosuspend"
"resume"
] @keyword
(BreakLabel (IDENTIFIER) @label) "fn" @keyword.function
(BlockLabel (IDENTIFIER) @label)
[ [
"true" "and"
"false" "or"
] @constant.builtin.boolean "orelse"
] @keyword.operator
[ [
"undefined" "try"
"unreachable" "unreachable"
"null" "return"
] @constant.builtin ] @keyword.control.return
[ [
"else"
"if" "if"
"else"
"switch" "switch"
"catch"
] @keyword.control.conditional ] @keyword.control.conditional
[ [
"for" "for"
"while" "while"
"break"
"continue"
] @keyword.control.repeat ] @keyword.control.repeat
[ [
"or" "usingnamespace"
"and" "export"
"orelse" ] @keyword.control.import
] @keyword.operator
[
"enum"
] @type.enum
[ [
"struct" "defer"
"union" "errdefer"
"packed" ] @keyword.control.exception
"opaque"
"export"
"extern"
"linksection"
] @keyword.storage.type
[ [
"const"
"var"
"threadlocal"
"allowzero"
"volatile" "volatile"
"allowzero"
"noalias"
"addrspace"
"align" "align"
"callconv"
"linksection"
"pub"
"inline"
"noinline"
"extern"
"comptime"
"packed"
"threadlocal"
] @keyword.storage.modifier ] @keyword.storage.modifier
[ ; Builtins
"try"
"error"
"catch"
] @keyword.control.exception
[ [
"fn" "c"
] @keyword.function "..."
] @variable.builtin
[ ((identifier) @variable.builtin
"test" (#eq? @variable.builtin "_"))
] @keyword
[ (calling_convention
"pub" (identifier) @variable.builtin)
"usingnamespace"
] @keyword.control.import
[ ; Modules
"return"
"break"
"continue"
] @keyword.control.return
[ (variable_declaration
"defer" (identifier) @variable ; TODO: module
"errdefer" (builtin_function
"async" (builtin_identifier) @keyword.control.import
"nosuspend" (#any-of? @keyword.control.import "@import" "@cImport")))
"await"
"suspend"
"resume"
] @function.macro
[ ; Functions
"comptime"
"inline"
"noinline"
"asm"
"callconv"
"noalias"
] @keyword.directive
[ (call_expression
(CompareOp) function: (field_expression
(BitwiseOp) member: (identifier) @function.method))
(BitShiftOp)
(AdditionOp)
(AssignOp)
(MultiplyOp)
(PrefixOp)
"*"
"**"
"->"
".?"
".*"
"?"
] @operator
[ (call_expression
";" function: (identifier) @function)
"."
"," (function_declaration
":" name: (identifier) @function)
] @punctuation.delimiter
(builtin_identifier) @function.builtin
; Fields
(field_initializer
.
(identifier) @variable.other.member)
(field_expression
(_)
member: (identifier) @variable.other.member)
(container_field
name: (identifier) @variable.other.member)
(initializer_list
(assignment_expression
left: (field_expression
.
member: (identifier) @variable.other.member)))
; Labels
(block_label (identifier) @label)
(break_label (identifier) @label)
; Constants
((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z_0-9]+$"))
[ [
".." "null"
"..." "undefined"
] @punctuation.special ] @constant.builtin
(field_expression
.
member: (identifier) @constant)
(enum_declaration
(container_field
type: (identifier) @constant))
; 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)
])
[ [
"[" (builtin_type)
"]" "anyframe"
"(" ] @type.builtin
")"
"{" ; Parameters
"}"
(Payload "|") (parameter
(PtrPayload "|") name: (identifier) @variable.parameter)
(PtrIndexPayload "|")
] @punctuation.bracket ; Variables
(ERROR) @keyword.control.exception (identifier) @variable

@ -1,13 +1,7 @@
[ [
(AsmExpr) (block)
(AssignExpr) (switch_expression)
(Block) (initializer_list)
(BlockExpr)
(ContainerDecl)
(ErrorUnionExpr)
(InitList)
(SwitchExpr)
(TestDecl)
] @indent ] @indent
[ [

@ -1,2 +1,2 @@
([(line_comment) (doc_comment)] @injection.content ((comment) @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment"))

@ -1,23 +1,22 @@
(Decl (FnProto) (function_declaration
(_) @function.inside) @function.around body: (_) @function.inside) @function.around
(TestDecl (_) @test.inside) @test.around (test_declaration (_) (block) @test.inside) @test.around
; matches all of: struct, enum, union ; matches all of: struct, enum, union
; this unfortunately cannot be split up because ; this unfortunately cannot be split up because
; of the way struct "container" types are defined ; of the way struct "container" types are defined
(Decl (VarDecl (ErrorUnionExpr (SuffixExpr (ContainerDecl (variable_declaration (identifier) (struct_declaration
(_) @class.inside))))) @class.around (_) @class.inside)) @class.around
(Decl (VarDecl (ErrorUnionExpr (SuffixExpr (ErrorSetDecl (variable_declaration (identifier) (enum_declaration
(_) @class.inside))))) @class.around (_) @class.inside)) @class.around
(ParamDeclList (variable_declaration (identifier) (enum_declaration
(_) @class.inside)) @class.around
(parameters
((_) @parameter.inside . ","? @parameter.around) @parameter.around) ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
[ (comment) @comment.inside
(doc_comment) (comment)+ @comment.around
(line_comment)
] @comment.inside
(line_comment)+ @comment.around
(doc_comment)+ @comment.around

Loading…
Cancel
Save