File tree 1 file changed +17
-2
lines changed
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 1
1
" Vim indent file
2
2
" Language: Rust
3
3
" Author: Chris Morgan <[email protected] >
4
- " Last Change: 2013 Jul 10
4
+ " Last Change: 2013 Oct 29
5
5
6
6
" Only load this indent file when no other was loaded.
7
7
if exists (" b:did_indent" )
@@ -104,8 +104,23 @@ function GetRustIndent(lnum)
104
104
let prevline = s: get_line_trimmed (prevnonblank (a: lnum - 1 ))
105
105
if prevline[len (prevline) - 1 ] == " ,"
106
106
\ && s: get_line_trimmed (a: lnum ) !~ " ^\\ s*[\\ [\\ ]{}]"
107
+ \ && prevline !~ " ^\\ s*fn\\ s"
107
108
" 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.
109
124
return GetRustIndent (a: lnum - 1 )
110
125
endif
111
126
You can’t perform that action at this time.
0 commit comments