mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-12 08:20:05 -04:00
Added Zig grammar
This commit is contained in:
parent
74234bc0e0
commit
597ec69378
7 changed files with 266 additions and 0 deletions
|
|
@ -188,6 +188,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||||
- [x] [verilog](https://github.com/tree-sitter/tree-sitter-verilog) (maintained by @zegervdv)
|
- [x] [verilog](https://github.com/tree-sitter/tree-sitter-verilog) (maintained by @zegervdv)
|
||||||
- [x] [vue](https://github.com/ikatyang/tree-sitter-vue) (maintained by @WhyNotHugo)
|
- [x] [vue](https://github.com/ikatyang/tree-sitter-vue) (maintained by @WhyNotHugo)
|
||||||
- [ ] [yaml](https://github.com/ikatyang/tree-sitter-yaml)
|
- [ ] [yaml](https://github.com/ikatyang/tree-sitter-yaml)
|
||||||
|
- [ ] [zig](https://github.com/Himujjal/tree-sitter-zig)
|
||||||
<!--parserinfo-->
|
<!--parserinfo-->
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,5 +166,8 @@
|
||||||
},
|
},
|
||||||
"yaml": {
|
"yaml": {
|
||||||
"revision": "59bf31b8a2138408de3f06d2f89fe86b8cfc302b"
|
"revision": "59bf31b8a2138408de3f06d2f89fe86b8cfc302b"
|
||||||
|
},
|
||||||
|
"zig": {
|
||||||
|
"revision": "da6d85db0e66f3b76d70ff5c2b119803ae206d02"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -524,6 +524,15 @@ list.bibtex = {
|
||||||
filetype = 'bib',
|
filetype = 'bib',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.zig = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/Himujjal/tree-sitter-zig",
|
||||||
|
files = { "src/parser.c" }
|
||||||
|
},
|
||||||
|
filetype = "zig",
|
||||||
|
maintainers = { "@Himujjal" }
|
||||||
|
}
|
||||||
|
|
||||||
local M = {
|
local M = {
|
||||||
list = list
|
list = list
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
queries/zig/folds.scm
Normal file
15
queries/zig/folds.scm
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
[
|
||||||
|
(block)
|
||||||
|
(comptime_block)
|
||||||
|
(defer_block)
|
||||||
|
(suspend_block)
|
||||||
|
(resume_block)
|
||||||
|
(if_expression)
|
||||||
|
(switch_block)
|
||||||
|
(for_expression)
|
||||||
|
(test_expression)
|
||||||
|
(struct_expression)
|
||||||
|
(anonymous_struct_enum)
|
||||||
|
(union_expression)
|
||||||
|
(enum_expression)
|
||||||
|
] @fold
|
||||||
183
queries/zig/highlights.scm
Normal file
183
queries/zig/highlights.scm
Normal file
|
|
@ -0,0 +1,183 @@
|
||||||
|
;; Assume all-caps names are constants
|
||||||
|
|
||||||
|
; (identifier) @variable
|
||||||
|
|
||||||
|
(parameter (identifier) @variable)
|
||||||
|
|
||||||
|
; ((identifier) @constant
|
||||||
|
; (#vim-match? @constant "^[A-Z][A-Z\\d_]+$'"))
|
||||||
|
|
||||||
|
; function definition
|
||||||
|
(function_signature
|
||||||
|
(identifier) @function
|
||||||
|
)
|
||||||
|
|
||||||
|
(function_declaration (identifier) @function)
|
||||||
|
|
||||||
|
; Function calls
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @function)
|
||||||
|
|
||||||
|
(build_in_call_expr
|
||||||
|
function: (identifier) @attribute)
|
||||||
|
|
||||||
|
;; other identifiers
|
||||||
|
(type_identifier) @type
|
||||||
|
(primitive_type) @type.builtin
|
||||||
|
(field_identifier) @property
|
||||||
|
|
||||||
|
(line_comment) @comment
|
||||||
|
(doc_comment) @comment
|
||||||
|
|
||||||
|
(char_literal) @number
|
||||||
|
(integer_literal) @number
|
||||||
|
(float_literal) @number
|
||||||
|
|
||||||
|
(boolean_literal) @constant.builtin
|
||||||
|
(undefined_literal) @constant.builtin
|
||||||
|
(null_literal) @constant.builtin
|
||||||
|
|
||||||
|
(string_literal) @string
|
||||||
|
(multiline_string_literal) @string
|
||||||
|
|
||||||
|
(escape_sequence) @constant.builtin
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[
|
||||||
|
"align"
|
||||||
|
"allowzero"
|
||||||
|
; "and"
|
||||||
|
; "anyframe"
|
||||||
|
; "anytype"
|
||||||
|
;"asm"
|
||||||
|
; "async"
|
||||||
|
"await"
|
||||||
|
"break"
|
||||||
|
; "callconv"
|
||||||
|
; "catch"
|
||||||
|
"comptime"
|
||||||
|
"const"
|
||||||
|
"continue"
|
||||||
|
"defer"
|
||||||
|
"else"
|
||||||
|
"enum"
|
||||||
|
"errdefer"
|
||||||
|
"error"
|
||||||
|
"export"
|
||||||
|
"extern"
|
||||||
|
"false"
|
||||||
|
; "fn"
|
||||||
|
"for"
|
||||||
|
"if"
|
||||||
|
"inline"
|
||||||
|
; "noalias"
|
||||||
|
; "nosuspend"
|
||||||
|
; "noinline"
|
||||||
|
"null"
|
||||||
|
; "opaque"
|
||||||
|
; "or"
|
||||||
|
; "orelse"
|
||||||
|
; "packed"
|
||||||
|
"pub"
|
||||||
|
"resume"
|
||||||
|
"return"
|
||||||
|
; "linksection"
|
||||||
|
"struct"
|
||||||
|
"suspend"
|
||||||
|
"switch"
|
||||||
|
"test"
|
||||||
|
; "threadlocal"
|
||||||
|
"true"
|
||||||
|
"try"
|
||||||
|
; "undefined"
|
||||||
|
"union"
|
||||||
|
;"unreachable"
|
||||||
|
"usingnamespace"
|
||||||
|
"var"
|
||||||
|
"volatile"
|
||||||
|
"while"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
"fn" @keyword.function
|
||||||
|
|
||||||
|
[
|
||||||
|
"continue"
|
||||||
|
"else"
|
||||||
|
"if"
|
||||||
|
"switch"
|
||||||
|
] @conditional
|
||||||
|
|
||||||
|
[
|
||||||
|
"for"
|
||||||
|
"while"
|
||||||
|
] @repeat
|
||||||
|
|
||||||
|
(assignment_modifier) @attribute
|
||||||
|
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
[
|
||||||
|
"&"
|
||||||
|
"&="
|
||||||
|
"*"
|
||||||
|
"*="
|
||||||
|
;"*%"
|
||||||
|
"*%="
|
||||||
|
;"^"
|
||||||
|
"^="
|
||||||
|
":"
|
||||||
|
","
|
||||||
|
"."
|
||||||
|
".."
|
||||||
|
"..."
|
||||||
|
".*"
|
||||||
|
".?"
|
||||||
|
"="
|
||||||
|
;"=="
|
||||||
|
"=>"
|
||||||
|
"!"
|
||||||
|
;"!="
|
||||||
|
;"<"
|
||||||
|
;"<<"
|
||||||
|
"<<="
|
||||||
|
;"<="
|
||||||
|
"-"
|
||||||
|
"-="
|
||||||
|
"-%"
|
||||||
|
"-%="
|
||||||
|
;"->"
|
||||||
|
;"%"
|
||||||
|
"%="
|
||||||
|
"|"
|
||||||
|
;"||"
|
||||||
|
"|="
|
||||||
|
;"+"
|
||||||
|
;"++"
|
||||||
|
"+="
|
||||||
|
;"+%"
|
||||||
|
"+%="
|
||||||
|
"c\""
|
||||||
|
"?"
|
||||||
|
;">"
|
||||||
|
;">>"
|
||||||
|
">>="
|
||||||
|
;">="
|
||||||
|
;"/"
|
||||||
|
"/="
|
||||||
|
"~"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
[
|
||||||
|
";"
|
||||||
|
"."
|
||||||
|
","
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
30
queries/zig/indents.scm
Normal file
30
queries/zig/indents.scm
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
[
|
||||||
|
(block)
|
||||||
|
(comptime_block)
|
||||||
|
(defer_block)
|
||||||
|
(suspend_block)
|
||||||
|
(resume_block)
|
||||||
|
(if_expression)
|
||||||
|
(while_expression)
|
||||||
|
(for_expression)
|
||||||
|
(test_expression)
|
||||||
|
(struct_expression)
|
||||||
|
(struct_construction)
|
||||||
|
(anonymous_struct_enum)
|
||||||
|
(enum_expression)
|
||||||
|
(union_expression)
|
||||||
|
] @indent
|
||||||
|
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @branch
|
||||||
|
|
||||||
|
[
|
||||||
|
(line_comment)
|
||||||
|
(multiline_string_literal)
|
||||||
|
] @ignore
|
||||||
25
queries/zig/locals.scm
Normal file
25
queries/zig/locals.scm
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
(function_declaration
|
||||||
|
name: (identifier) @definition.function
|
||||||
|
)
|
||||||
|
|
||||||
|
((type_identifier) @reference
|
||||||
|
(set! reference.kind "type"))
|
||||||
|
|
||||||
|
(assignment_statement
|
||||||
|
name: (identifier) @definition.var
|
||||||
|
)
|
||||||
|
|
||||||
|
(identifier) @reference
|
||||||
|
|
||||||
|
; Scopes
|
||||||
|
[
|
||||||
|
(block)
|
||||||
|
(comptime_block)
|
||||||
|
(defer_block)
|
||||||
|
(suspend_block)
|
||||||
|
(resume_block)
|
||||||
|
(if_expression)
|
||||||
|
(while_expression)
|
||||||
|
(for_expression)
|
||||||
|
(test_expression)
|
||||||
|
] @scope
|
||||||
Loading…
Add table
Add a link
Reference in a new issue