mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
indents: allow aligned_indent for unfinished calls in C and Python
This commit is contained in:
parent
62982378b8
commit
059fbc487c
7 changed files with 26 additions and 3 deletions
|
|
@ -122,7 +122,8 @@ function M.get_indent(lnum)
|
|||
is_processed = true
|
||||
end
|
||||
|
||||
if q.aligned_indent[node:id()] and srow ~= erow then
|
||||
-- do not indent for nodes that starts-and-ends on same line and starts on target line (lnum)
|
||||
if q.aligned_indent[node:id()] and srow ~= erow and (srow ~= lnum - 1) then
|
||||
local metadata = q.aligned_indent[node:id()]
|
||||
local opening_delimiter = metadata.delimiter:sub(1, 1)
|
||||
local o_delim_node, pos = get_matching_prev_sibling(node, { srow, #vim.fn.getline(srow + 1) - 1 }, function(n)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
(enumerator_list)
|
||||
(struct_specifier)
|
||||
(compound_literal_expression)
|
||||
(parameter_list)
|
||||
(initializer_list)
|
||||
(concatenated_string)
|
||||
(while_statement)
|
||||
|
|
@ -44,3 +43,8 @@
|
|||
] @ignore
|
||||
|
||||
(binary_expression) @auto
|
||||
|
||||
((ERROR (parameter_declaration)) @aligned_indent
|
||||
(#set! "delimiter" "()"))
|
||||
([(argument_list) (parameter_list)] @aligned_indent
|
||||
(#set! "delimiter" "()"))
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
condition: (parenthesized_expression) @aligned_indent
|
||||
(#set! "delimiter" "()")
|
||||
)
|
||||
((ERROR "(" . (_)) @aligned_indent
|
||||
(#set! "delimiter" "()"))
|
||||
((argument_list) @aligned_indent
|
||||
(#set! "delimiter" "()"))
|
||||
((argument_list) @aligned_indent
|
||||
|
|
|
|||
10
tests/indent/c/aligned_indent.c
Normal file
10
tests/indent/c/aligned_indent.c
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
void foo(int a,
|
||||
int b,
|
||||
int c);
|
||||
|
||||
void foo(int a,
|
||||
int b
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ int f4(
|
|||
}
|
||||
|
||||
int f5(int x,
|
||||
int y)
|
||||
int y)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
3
tests/indent/c/initializer_list.c
Normal file
3
tests/indent/c/initializer_list.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
int a[] = {
|
||||
1, 2, 3,
|
||||
4};
|
||||
|
|
@ -9,3 +9,6 @@ aligned_indent(1,
|
|||
aligned_indent(1,
|
||||
2
|
||||
)
|
||||
|
||||
foodsadsa(sdada,
|
||||
2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue