summaryrefslogtreecommitdiff
path: root/vendor/queries/zig/textobjects.scm
blob: 1c40b1370c9aefc945b603f88479877cfa420288 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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