From c5d96bec3d5279904525292ef933a985a974b017 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 17:13:46 -0300 Subject: Zig has textobjects: helix's query, ported to the zig grammar pardes builds pardes builds maxxnino/tree-sitter-zig, whose node names are not those of the grammar helix's query targets, so the query is ported by hand (vendor/queries/zig, its MPL header saying it is modified and how): a function is a Decl holding an FnProto and a Block with pub beside it, struct/enum/union one ContainerDecl, parameters and arguments ParamDeclList and FnCallArguments, and comments come in three kinds. That grammar's comments take their line's newline, and a node ending in a newline is now taken without it, as helix's grammars have it. The replay test gains fifteen Zig cases from the installed hx; none walks call arguments, which the reference helix counts as parameters and 25.07.1's query does not. Co-Authored-By: Claude Opus 5.5 --- vendor/queries/zig/textobjects.scm | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 vendor/queries/zig/textobjects.scm (limited to 'vendor/queries/zig/textobjects.scm') diff --git a/vendor/queries/zig/textobjects.scm b/vendor/queries/zig/textobjects.scm new file mode 100644 index 00000000..1c40b137 --- /dev/null +++ b/vendor/queries/zig/textobjects.scm @@ -0,0 +1,40 @@ +; Adapted from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/zig/textobjects.scm, MODIFIED for the zig grammar pardes +; builds (maxxnino/tree-sitter-zig), whose node names differ from the +; tree-sitter-grammars one helix uses: function_declaration is a Decl holding +; an FnProto and a Block, with `pub` a sibling before it; variable_declaration +; is VarDecl; struct/enum/union are one ContainerDecl; parameters and +; arguments are ParamDeclList and FnCallArguments; comments come in three +; kinds. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +(_ + "pub"? @function.around + . + (Decl + (FnProto) + (Block) @function.inside) @function.around) + +(TestDecl (Block) @test.inside) @test.around + +; matches all of: struct, enum, union (one ContainerDecl in this grammar), +; `pub` with them where there is one +(_ + "pub"? @class.around + . + (Decl + (VarDecl + (ErrorUnionExpr + (SuffixExpr + (ContainerDecl + [(ContainerField) (Decl) (TestDecl) (ComptimeDecl)] @class.inside))))) @class.around) + +(ParamDeclList + ((ParamDecl) @parameter.inside . ","? @parameter.around) @parameter.around) + +(FnCallArguments + ((_) @parameter.inside . ","? @parameter.around) @parameter.around) + +[(line_comment) (doc_comment) (container_doc_comment)] @comment.inside +[(line_comment) (doc_comment) (container_doc_comment)]+ @comment.around -- cgit v1.3