File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 11" Vim indent file
22" Language: Rust
33" Author: Chris Morgan <[email protected] >4- " Last Change: 2013 Jul 10
4+ " Last Change: 2013 Oct 29
55
66" Only load this indent file when no other was loaded.
77if exists (" b:did_indent" )
@@ -104,8 +104,23 @@ function GetRustIndent(lnum)
104104 let prevline = s: get_line_trimmed (prevnonblank (a: lnum - 1 ))
105105 if prevline[len (prevline) - 1 ] == " ,"
106106 \ && s: get_line_trimmed (a: lnum ) !~ " ^\\ s*[\\ [\\ ]{}]"
107+ \ && prevline !~ " ^\\ s*fn\\ s"
107108 " Oh ho! The previous line ended in a comma! I bet cindent will try to
108- " take this too far... For now, let's use the previous line's indent
109+ " take this too far... For now, let's normally use the previous line's
110+ " indent.
111+
112+ " One case where this doesn't work out is where *this* line contains
113+ " square or curly brackets; then we normally *do* want to be indenting
114+ " further.
115+ "
116+ " Another case where we don't want to is one like a function
117+ " definition with arguments spread over multiple lines:
118+ "
119+ " fn foo(baz: Baz,
120+ " baz: Baz) // <-- cindent gets this right by itself
121+ "
122+ " There are probably other cases where we don't want to do this as
123+ " well. Add them as needed.
109124 return GetRustIndent (a: lnum - 1 )
110125 endif
111126
You can’t perform that action at this time.
0 commit comments