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