|
1 | 1 | " Vim indent file
|
2 | 2 | " Language: Rust
|
3 | 3 | " Author: Chris Morgan <[email protected]>
|
4 |
| -" Last Change: 2013 Oct 29 |
| 4 | +" Last Change: 2014 Sep 13 |
5 | 5 |
|
6 | 6 | " Only load this indent file when no other was loaded.
|
7 | 7 | if exists("b:did_indent")
|
|
10 | 10 | let b:did_indent = 1
|
11 | 11 |
|
12 | 12 | setlocal cindent
|
13 |
| -setlocal cinoptions=L0,(0,Ws,JN,j1 |
| 13 | +setlocal cinoptions=L0,(0,Ws,J1,j1 |
14 | 14 | setlocal cinkeys=0{,0},!^F,o,O,0[,0]
|
15 | 15 | " Don't think cinwords will actually do anything at all... never mind
|
16 | 16 | setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
|
@@ -151,42 +151,7 @@ function GetRustIndent(lnum)
|
151 | 151 | "
|
152 | 152 | " There are probably other cases where we don't want to do this as
|
153 | 153 | " well. Add them as needed.
|
154 |
| - return GetRustIndent(a:lnum - 1) |
155 |
| - endif |
156 |
| - |
157 |
| - " cindent doesn't do the module scope well at all; e.g.:: |
158 |
| - " |
159 |
| - " static FOO : &'static [bool] = [ |
160 |
| - " true, |
161 |
| - " false, |
162 |
| - " false, |
163 |
| - " true, |
164 |
| - " ]; |
165 |
| - " |
166 |
| - " uh oh, next statement is indented further! |
167 |
| - |
168 |
| - " Note that this does *not* apply the line continuation pattern properly; |
169 |
| - " that's too hard to do correctly for my liking at present, so I'll just |
170 |
| - " start with these two main cases (square brackets and not returning to |
171 |
| - " column zero) |
172 |
| - |
173 |
| - call cursor(a:lnum, 1) |
174 |
| - if searchpair('{\|(', '', '}\|)', 'nbW', |
175 |
| - \ 's:is_string_comment(line("."), col("."))') == 0 |
176 |
| - if searchpair('\[', '', '\]', 'nbW', |
177 |
| - \ 's:is_string_comment(line("."), col("."))') == 0 |
178 |
| - " Global scope, should be zero |
179 |
| - return 0 |
180 |
| - else |
181 |
| - " At the module scope, inside square brackets only |
182 |
| - "if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum |
183 |
| - if line =~ "^\\s*]" |
184 |
| - " It's the closing line, dedent it |
185 |
| - return 0 |
186 |
| - else |
187 |
| - return &shiftwidth |
188 |
| - endif |
189 |
| - endif |
| 154 | + return indent(prevlinenum) |
190 | 155 | endif
|
191 | 156 |
|
192 | 157 | " Fall back on cindent, which does it mostly right
|
|
0 commit comments