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 (expression body fallback)
 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(function_signature) @function.around
 64
 65(generator_function
 66  body: (_
 67    "{"
 68    (_)* @function.inside
 69    "}")) @function.around
 70
 71(generator_function_declaration
 72  body: (_
 73    "{"
 74    (_)* @function.inside
 75    "}")) @function.around
 76
 77(class_declaration
 78  body: (_
 79    "{"
 80    [
 81      (_)
 82      ";"?
 83    ]* @class.inside
 84    "}")) @class.around
 85
 86(class
 87  body: (_
 88    "{"
 89    (_)* @class.inside
 90    "}")) @class.around
 91
 92(interface_declaration
 93  body: (_
 94    "{"
 95    [
 96      (_)
 97      ";"?
 98    ]* @class.inside
 99    "}")) @class.around
100
101(enum_declaration
102  body: (_
103    "{"
104    [
105      (_)
106      ","?
107    ]* @class.inside
108    "}")) @class.around
109
110(ambient_declaration
111  (module
112    body: (_
113      "{"
114      [
115        (_)
116        ";"?
117      ]* @class.inside
118      "}"))) @class.around
119
120(internal_module
121  body: (_
122    "{"
123    [
124      (_)
125      ";"?
126    ]* @class.inside
127    "}")) @class.around
128
129(type_alias_declaration) @class.around