feat: rewrite indent module

This commit is contained in:
Munif Tanjim 2022-01-18 21:17:26 +06:00 committed by Christian Clason
parent baf94219aa
commit c0110e34aa
13 changed files with 136 additions and 182 deletions

View file

@ -8,18 +8,38 @@
(enumerator_list)
(struct_specifier)
(compound_literal_expression)
(parameter_list)
(initializer_list)
(concatenated_string)
(while_statement)
(for_statement)
(switch_statement)
] @indent
(if_statement condition: (_) @indent)
((if_statement
consequence: (_) @_consequence
(#not-has-type? @_consequence compound_statement)
) @indent)
(init_declarator
value: [
(binary_expression)
] @indent)
[
"#define"
"#ifdef"
"#if"
"#else"
"else"
"#endif"
"{"
")"
"}"
] @branch
[
(comment)
(preproc_function_def)
(preproc_arg)
(string_literal)
] @ignore
(binary_expression) @auto

View file

@ -1,7 +1,8 @@
; inherits: c
[
(field_declaration_list)
(class_specifier)
(condition_clause)
] @indent
(access_specifier) @branch

View file

@ -1,7 +1,6 @@
[
(function_definition)
(function_declaration)
(variable_declaration)
(field)
(do_statement)
(while_statement)
@ -11,8 +10,13 @@
(return_statement)
(table_constructor)
(arguments)
(return_statement)
] @indent
(return_statement
(expression_list
(function_call))) @dedent
[
"do"
"end"
@ -30,4 +34,4 @@
(comment) @ignore
(string) @ignore
(string) @auto

View file

@ -23,8 +23,11 @@
(parameters)
(binary_operator)
(lambda)
(function_definition)
(class_definition)
(concatenated_string)
] @indent
[
@ -37,12 +40,4 @@
(finally_clause)
] @branch
[
(return_statement)
(pass_statement)
(raise_statement)
] @return
[
(string)
] @ignore
(string) @auto

View file

@ -16,19 +16,31 @@
(block)
(where_clause)
(use_list)
(array_expression)
(ordered_field_declaration_list)
(field_declaration_list)
(enum_variant_list)
(parameters)
(token_tree)
(macro_definition)
] @indent
(trait_item body: (_) @indent)
(string_literal (escape_sequence)) @indent
(impl_item (where_clause) @dedent)
[
"where"
"("
")"
"["
"]"
"{"
"}"
] @branch
(impl_item (declaration_list) @branch)
[
(line_comment)
(raw_string_literal)
(string_literal)
] @ignore
(raw_string_literal) @auto