about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-04-18 15:01:22 -0700
committerbors <bors@rust-lang.org>2014-04-18 15:01:22 -0700
commitb75683cadf6c4c55360202cd6a0106be80532451 (patch)
tree27bd6775c85f8df035a520bb499312168dd4caf4
parentc44c7abb42df8f13efdaa8b871893ad1dd5941e4 (diff)
parent59f3414a4a66a132648bd89ae697924304715bd3 (diff)
downloadrust-b75683cadf6c4c55360202cd6a0106be80532451.tar.gz
rust-b75683cadf6c4c55360202cd6a0106be80532451.zip
auto merge of #13600 : brandonw/rust/master, r=brson
When calling a function, or anything with nested parens,
default to cindent's indent. The least error-prone way I
could think of identifying this is to look for a line
that ends with a ',', as well as a non-zero number of
any character except parens before the comma, and
then an open paren.

This will overlap with the previous rule accounting for
function definitions, but that should be fine because
it is also using cindent.
-rw-r--r--src/etc/vim/indent/rust.vim11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/etc/vim/indent/rust.vim b/src/etc/vim/indent/rust.vim
index 1f08c519021..f7ac357b23a 100644
--- a/src/etc/vim/indent/rust.vim
+++ b/src/etc/vim/indent/rust.vim
@@ -105,6 +105,7 @@ function GetRustIndent(lnum)
 	if prevline[len(prevline) - 1] == ","
 				\ && s:get_line_trimmed(a:lnum) !~ "^\\s*[\\[\\]{}]"
 				\ && prevline !~ "^\\s*fn\\s"
+				\ && prevline !~ "\\([^\\(\\)]\+,$"
 		" Oh ho! The previous line ended in a comma! I bet cindent will try to
 		" take this too far... For now, let's normally use the previous line's
 		" indent.
@@ -119,6 +120,16 @@ function GetRustIndent(lnum)
 		" fn foo(baz: Baz,
 		"        baz: Baz) // <-- cindent gets this right by itself
 		"
+		" Another case is similar to the previous, except calling a function
+		" instead of defining it, or any conditional expression that leaves
+		" an open paren:
+		"
+		" foo(baz,
+		"     baz);
+		"
+		" if baz && (foo ||
+		"            bar) {
+		"
 		" There are probably other cases where we don't want to do this as
 		" well. Add them as needed.
 		return GetRustIndent(a:lnum - 1)