textobjects.scm

 1(comment)+ @comment.around
 2
 3(function_declaration
 4  body: (_
 5    "{"
 6    (_)* @function.inside
 7    "}")) @function.around
 8
 9(method_definition
10  body: (_
11    "{"
12    (_)* @function.inside
13    "}")) @function.around
14
15(function_expression
16  body: (_
17    "{"
18    (_)* @function.inside
19    "}")) @function.around
20
21((arrow_function
22  body: (statement_block
23    "{"
24    (_)* @function.inside
25    "}")) @function.around
26  (#not-has-parent? @function.around variable_declarator))
27
28; Arrow function in variable declaration - capture the full declaration
29([
30  (lexical_declaration
31    (variable_declarator
32      value: (arrow_function
33        body: (statement_block
34          "{"
35          (_)* @function.inside
36          "}"))))
37  (variable_declaration
38    (variable_declarator
39      value: (arrow_function
40        body: (statement_block
41          "{"
42          (_)* @function.inside
43          "}"))))
44]) @function.around
45
46; Arrow function in variable declaration (captures body for expression-bodied arrows)
47([
48  (lexical_declaration
49    (variable_declarator
50      value: (arrow_function
51        body: (_) @function.inside)))
52  (variable_declaration
53    (variable_declarator
54      value: (arrow_function
55        body: (_) @function.inside)))
56]) @function.around
57
58; Catch-all for arrow functions in other contexts (callbacks, etc.)
59((arrow_function
60  body: (_) @function.inside) @function.around
61  (#not-has-parent? @function.around variable_declarator))
62
63(generator_function
64  body: (_
65    "{"
66    (_)* @function.inside
67    "}")) @function.around
68
69(generator_function_declaration
70  body: (_
71    "{"
72    (_)* @function.inside
73    "}")) @function.around
74
75(class_declaration
76  body: (_
77    "{"
78    [
79      (_)
80      ";"?
81    ]* @class.inside
82    "}")) @class.around
83
84(class
85  body: (_
86    "{"
87    [
88      (_)
89      ";"?
90    ]* @class.inside
91    "}")) @class.around