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.
This commit is contained in:
Kevin Ballard 2014-07-05 20:21:34 -07:00
parent 6f46621b33
commit c6492040b2
2 changed files with 24 additions and 3 deletions

View File

@ -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

View File

@ -3,7 +3,7 @@
" Maintainer: Patrick Walton <pcwalton@mozilla.com>
" Maintainer: Ben Blum <bblum@cs.cmu.edu>
" Maintainer: Chris Morgan <me@chrismorgan.info>
" 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