diff options
| author | Himujjal <himu@tuta.io> | 2021-03-23 06:18:43 +0530 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2021-03-23 12:36:34 +0100 |
| commit | 597ec69378c230bd7b4d3f55d552eb51f4f2afcd (patch) | |
| tree | e87dcf45a0fe88bdd370984f5bf47ee3c3739791 /queries/zig | |
| parent | Update lockfile.json (diff) | |
| download | nvim-treesitter-597ec69378c230bd7b4d3f55d552eb51f4f2afcd.tar nvim-treesitter-597ec69378c230bd7b4d3f55d552eb51f4f2afcd.tar.gz nvim-treesitter-597ec69378c230bd7b4d3f55d552eb51f4f2afcd.tar.bz2 nvim-treesitter-597ec69378c230bd7b4d3f55d552eb51f4f2afcd.tar.lz nvim-treesitter-597ec69378c230bd7b4d3f55d552eb51f4f2afcd.tar.xz nvim-treesitter-597ec69378c230bd7b4d3f55d552eb51f4f2afcd.tar.zst nvim-treesitter-597ec69378c230bd7b4d3f55d552eb51f4f2afcd.zip | |
Added Zig grammar
Diffstat (limited to 'queries/zig')
| -rw-r--r-- | queries/zig/folds.scm | 15 | ||||
| -rw-r--r-- | queries/zig/highlights.scm | 183 | ||||
| -rw-r--r-- | queries/zig/indents.scm | 30 | ||||
| -rw-r--r-- | queries/zig/locals.scm | 25 |
4 files changed, 253 insertions, 0 deletions
diff --git a/queries/zig/folds.scm b/queries/zig/folds.scm new file mode 100644 index 000000000..2781c0f2a --- /dev/null +++ b/queries/zig/folds.scm @@ -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 diff --git a/queries/zig/highlights.scm b/queries/zig/highlights.scm new file mode 100644 index 000000000..b9d3b25ad --- /dev/null +++ b/queries/zig/highlights.scm @@ -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 + diff --git a/queries/zig/indents.scm b/queries/zig/indents.scm new file mode 100644 index 000000000..0502fdcaa --- /dev/null +++ b/queries/zig/indents.scm @@ -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 diff --git a/queries/zig/locals.scm b/queries/zig/locals.scm new file mode 100644 index 000000000..7767686af --- /dev/null +++ b/queries/zig/locals.scm @@ -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 |
