From c6492040b260b09e92526e10807dfa7e71f8c901 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Sat, 5 Jul 2014 20:21:34 -0700 Subject: [PATCH] Define a new setting g:rust_fold g:rust_fold allows folding to be enabled. This lets the user turn on folding without having to define autocommands. --- src/etc/vim/doc/rust.txt | 12 ++++++++++++ src/etc/vim/syntax/rust.vim | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/etc/vim/doc/rust.txt b/src/etc/vim/doc/rust.txt index 96ed69db635..15b231df8fe 100644 --- a/src/etc/vim/doc/rust.txt +++ b/src/etc/vim/doc/rust.txt @@ -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/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index 6285eb6895d..b29c2ce2462 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