diff --git a/src/etc/vim/doc/rust.txt b/src/etc/vim/doc/rust.txt index 96ed69db63529..80f8c3ca5e1ee 100644 --- a/src/etc/vim/doc/rust.txt +++ b/src/etc/vim/doc/rust.txt @@ -1,7 +1,7 @@ *rust.txt* Filetype plugin for Rust ============================================================================== -CONTENTS *rust* +CONTENTS *rust* *ft-rust* 1. Introduction |rust-intro| 2. Settings |rust-settings| @@ -53,6 +53,18 @@ g:rust_conceal_pub~ let g:rust_conceal_pub = 1 < + *g:rust_fold* +g:rust_fold~ + Set this option to turn on |folding|: > + let g:rust_fold = 1 +< + Value Effect ~ + 0 No folding + 1 Braced blocks are folded. All folds are open by + default. + 2 Braced blocks are folded. 'foldlevel' is left at the + global value (all folds are closed by default). + *g:rust_bang_comment_leader* g:rust_bang_comment_leader~ Set this option to 1 to preserve the leader on multi-line doc comments diff --git a/src/etc/vim/ftplugin/rust.vim b/src/etc/vim/ftplugin/rust.vim index 16ed43415c3ef..39edc1f9a20d7 100644 --- a/src/etc/vim/ftplugin/rust.vim +++ b/src/etc/vim/ftplugin/rust.vim @@ -2,7 +2,7 @@ " Description: Vim syntax file for Rust " Maintainer: Chris Morgan " Maintainer: Kevin Ballard -" Last Change: May 27, 2014 +" Last Change: Jul 07, 2014 if exists("b:did_ftplugin") finish @@ -35,7 +35,9 @@ silent! setlocal formatoptions+=j " otherwise it's better than nothing. setlocal smartindent nocindent -setlocal tabstop=4 shiftwidth=4 expandtab +setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab + +setlocal textwidth=99 " This includeexpr isn't perfect, but it's a good start setlocal includeexpr=substitute(v:fname,'::','/','g') @@ -93,7 +95,8 @@ endif " Cleanup {{{1 let b:undo_ftplugin = " - \setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< + \ setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< + \|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth< \|if exists('b:rust_original_delimitMate_excluded_regions') \|let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions \|unlet b:rust_original_delimitMate_excluded_regions diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index 6285eb6895df0..b29c2ce246235 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -3,7 +3,7 @@ " Maintainer: Patrick Walton " Maintainer: Ben Blum " Maintainer: Chris Morgan -" Last Change: 2014 Feb 27 +" Last Change: July 06, 2014 if version < 600 syntax clear @@ -11,6 +11,17 @@ elseif exists("b:current_syntax") finish endif +" Fold settings {{{1 + +if has("folding") && exists('g:rust_fold') && g:rust_fold != 0 + setlocal foldmethod=syntax + if g:rust_fold == 2 + setlocal foldlevel< + else + setlocal foldlevel=99 + endif +endif + " Syntax definitions {{{1 " Basic keywords {{{2 syn keyword rustConditional match if else @@ -213,8 +224,6 @@ syn keyword rustTodo contained TODO FIXME XXX NB NOTE " Trivial folding rules to begin with. " TODO: use the AST to make really good folding syn region rustFoldBraces start="{" end="}" transparent fold -" If you wish to enable this, setlocal foldmethod=syntax -" It's not enabled by default as it would drive some people mad. " Default highlighting {{{1 hi def link rustDecNumber rustNumber