diff options
| author | Julian Orth <ju.orth@gmail.com> | 2014-09-18 22:16:47 +0200 |
|---|---|---|
| committer | Julian Orth <ju.orth@gmail.com> | 2014-09-18 22:16:47 +0200 |
| commit | 39116d01914854882f62b1306e8b96fb0b4f9842 (patch) | |
| tree | 8e68ab7e6d60d539c8286d1d4c2a70999616c84b /src | |
| parent | 9c72da52514428c187742de3e8b796949e72d34f (diff) | |
| download | rust-39116d01914854882f62b1306e8b96fb0b4f9842.tar.gz rust-39116d01914854882f62b1306e8b96fb0b4f9842.zip | |
fix for vim < 7.4.355
Diffstat (limited to 'src')
| -rw-r--r-- | src/etc/vim/indent/rust.vim | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/etc/vim/indent/rust.vim b/src/etc/vim/indent/rust.vim index 3c733d39da4..300d7dacfa9 100644 --- a/src/etc/vim/indent/rust.vim +++ b/src/etc/vim/indent/rust.vim @@ -154,6 +154,43 @@ function GetRustIndent(lnum) return indent(prevlinenum) endif + if !has("patch-7.4.355") + " cindent before 7.4.355 doesn't do the module scope well at all; e.g.:: + " + " static FOO : &'static [bool] = [ + " true, + " false, + " false, + " true, + " ]; + " + " uh oh, next statement is indented further! + + " Note that this does *not* apply the line continuation pattern properly; + " that's too hard to do correctly for my liking at present, so I'll just + " start with these two main cases (square brackets and not returning to + " column zero) + + call cursor(a:lnum, 1) + if searchpair('{\|(', '', '}\|)', 'nbW', + \ 's:is_string_comment(line("."), col("."))') == 0 + if searchpair('\[', '', '\]', 'nbW', + \ 's:is_string_comment(line("."), col("."))') == 0 + " Global scope, should be zero + return 0 + else + " At the module scope, inside square brackets only + "if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum + if line =~ "^\\s*]" + " It's the closing line, dedent it + return 0 + else + return &shiftwidth + endif + endif + endif + endif + " Fall back on cindent, which does it mostly right return cindent(a:lnum) endfunction |
