mirror of
https://github.com/nvim-treesitter/nvim-treesitter-context
synced 2024-09-16 14:14:03 +02:00
feat: adding generator to js/ts/tsx and improvements for ts (#234)
* feat: adding generator to js/ts/tsx and improvements for ts * reverting tests
This commit is contained in:
parent
3a48e2d3c9
commit
fc7db28056
4 changed files with 38 additions and 4 deletions
|
@ -10,6 +10,7 @@
|
|||
(expression_statement)
|
||||
(for_statement)
|
||||
(function_declaration)
|
||||
(generator_function_declaration)
|
||||
(jsx_element)
|
||||
(jsx_self_closing_element)
|
||||
(lexical_declaration)
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
) @context
|
||||
|
||||
([
|
||||
(arrow_function)
|
||||
(call_expression)
|
||||
(class_declaration)
|
||||
(else_clause)
|
||||
(expression_statement)
|
||||
(for_statement)
|
||||
(function_declaration)
|
||||
(interface_declaration)
|
||||
(jsx_element)
|
||||
(jsx_self_closing_element)
|
||||
|
@ -19,3 +17,15 @@
|
|||
(pair)
|
||||
(while_statement)
|
||||
] @context)
|
||||
|
||||
(arrow_function
|
||||
body: (_ (_) @context.end)
|
||||
) @context
|
||||
|
||||
(function_declaration
|
||||
body: (_ (_) @context.end)
|
||||
) @context
|
||||
|
||||
(generator_function_declaration
|
||||
body: (_ (_) @context.end)
|
||||
) @context
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
) @context
|
||||
|
||||
([
|
||||
(arrow_function)
|
||||
(call_expression)
|
||||
(class_declaration)
|
||||
(else_clause)
|
||||
(expression_statement)
|
||||
(for_statement)
|
||||
(function_declaration)
|
||||
(interface_declaration)
|
||||
(lexical_declaration)
|
||||
(method_definition)
|
||||
|
@ -17,3 +15,15 @@
|
|||
(pair)
|
||||
(while_statement)
|
||||
] @context)
|
||||
|
||||
(arrow_function
|
||||
body: (_ (_) @context.end)
|
||||
) @context
|
||||
|
||||
(function_declaration
|
||||
body: (_ (_) @context.end)
|
||||
) @context
|
||||
|
||||
(generator_function_declaration
|
||||
body: (_ (_) @context.end)
|
||||
) @context
|
||||
|
|
|
@ -44,6 +44,19 @@ function wrapInArray(obj: string | string[]) {
|
|||
|
||||
|
||||
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function* wrapInArray2(
|
||||
obj: string | string[]):
|
||||
string[] {
|
||||
if (typeof obj === "string") {
|
||||
return [obj];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue