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 - capture body as @function.inside
 47; (for statement blocks, the more specific pattern above captures just the contents)
 48([
 49  (lexical_declaration
 50    (variable_declarator
 51      value: (arrow_function
 52        body: (_) @function.inside)))
 53  (variable_declaration
 54    (variable_declarator
 55      value: (arrow_function
 56        body: (_) @function.inside)))
 57]) @function.around
 58
 59; Catch-all for arrow functions in other contexts (callbacks, etc.)
 60((arrow_function
 61  body: (_) @function.inside) @function.around
 62  (#not-has-parent? @function.around variable_declarator))
 63
 64(function_signature) @function.around
 65
 66(generator_function
 67  body: (_
 68    "{"
 69    (_)* @function.inside
 70    "}")) @function.around
 71
 72(generator_function_declaration
 73  body: (_
 74    "{"
 75    (_)* @function.inside
 76    "}")) @function.around
 77
 78(class_declaration
 79  body: (_
 80    "{"
 81    [
 82      (_)
 83      ";"?
 84    ]* @class.inside
 85    "}")) @class.around
 86
 87(class
 88  body: (_
 89    "{"
 90    (_)* @class.inside
 91    "}")) @class.around
 92
 93(interface_declaration
 94  body: (_
 95    "{"
 96    [
 97      (_)
 98      ";"?
 99    ]* @class.inside
100    "}")) @class.around
101
102(enum_declaration
103  body: (_
104    "{"
105    [
106      (_)
107      ","?
108    ]* @class.inside
109    "}")) @class.around
110
111(ambient_declaration
112  (module
113    body: (_
114      "{"
115      [
116        (_)
117        ";"?
118      ]* @class.inside
119      "}"))) @class.around
120
121(internal_module
122  body: (_
123    "{"
124    [
125      (_)
126      ";"?
127    ]* @class.inside
128    "}")) @class.around
129
130(type_alias_declaration) @class.around