Skip to content

Commit 316719e

Browse files
committed
auto merge of #15476 : kballard/rust/more_vim_tweaks, r=chris
Tweak the text editing settings (softtabstop, textwidth, etc). Add some settings to turn on folding and colorcolumn. Add the undo_ftplugin changes that my previous patch forgot.
2 parents 0582421 + 9dc667d commit 316719e

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

src/etc/vim/doc/rust.txt

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*rust.txt* Filetype plugin for Rust
22

33
==============================================================================
4-
CONTENTS *rust*
4+
CONTENTS *rust* *ft-rust*
55

66
1. Introduction |rust-intro|
77
2. Settings |rust-settings|
@@ -53,6 +53,18 @@ g:rust_conceal_pub~
5353
let g:rust_conceal_pub = 1
5454
<
5555

56+
*g:rust_fold*
57+
g:rust_fold~
58+
Set this option to turn on |folding|: >
59+
let g:rust_fold = 1
60+
<
61+
Value Effect ~
62+
0 No folding
63+
1 Braced blocks are folded. All folds are open by
64+
default.
65+
2 Braced blocks are folded. 'foldlevel' is left at the
66+
global value (all folds are closed by default).
67+
5668
*g:rust_bang_comment_leader*
5769
g:rust_bang_comment_leader~
5870
Set this option to 1 to preserve the leader on multi-line doc comments

src/etc/vim/ftplugin/rust.vim

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: Vim syntax file for Rust
33
" Maintainer: Chris Morgan <[email protected]>
44
" Maintainer: Kevin Ballard <[email protected]>
5-
" Last Change: May 27, 2014
5+
" Last Change: Jul 07, 2014
66

77
if exists("b:did_ftplugin")
88
finish
@@ -35,7 +35,9 @@ silent! setlocal formatoptions+=j
3535
" otherwise it's better than nothing.
3636
setlocal smartindent nocindent
3737

38-
setlocal tabstop=4 shiftwidth=4 expandtab
38+
setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
39+
40+
setlocal textwidth=99
3941

4042
" This includeexpr isn't perfect, but it's a good start
4143
setlocal includeexpr=substitute(v:fname,'::','/','g')
@@ -93,7 +95,8 @@ endif
9395
" Cleanup {{{1
9496

9597
let b:undo_ftplugin = "
96-
\setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd<
98+
\ setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd<
99+
\|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth<
97100
\|if exists('b:rust_original_delimitMate_excluded_regions')
98101
\|let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions
99102
\|unlet b:rust_original_delimitMate_excluded_regions

src/etc/vim/syntax/rust.vim

+12-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,25 @@
33
" Maintainer: Patrick Walton <[email protected]>
44
" Maintainer: Ben Blum <[email protected]>
55
" Maintainer: Chris Morgan <[email protected]>
6-
" Last Change: 2014 Feb 27
6+
" Last Change: July 06, 2014
77

88
if version < 600
99
syntax clear
1010
elseif exists("b:current_syntax")
1111
finish
1212
endif
1313

14+
" Fold settings {{{1
15+
16+
if has("folding") && exists('g:rust_fold') && g:rust_fold != 0
17+
setlocal foldmethod=syntax
18+
if g:rust_fold == 2
19+
setlocal foldlevel<
20+
else
21+
setlocal foldlevel=99
22+
endif
23+
endif
24+
1425
" Syntax definitions {{{1
1526
" Basic keywords {{{2
1627
syn keyword rustConditional match if else
@@ -213,8 +224,6 @@ syn keyword rustTodo contained TODO FIXME XXX NB NOTE
213224
" Trivial folding rules to begin with.
214225
" TODO: use the AST to make really good folding
215226
syn region rustFoldBraces start="{" end="}" transparent fold
216-
" If you wish to enable this, setlocal foldmethod=syntax
217-
" It's not enabled by default as it would drive some people mad.
218227

219228
" Default highlighting {{{1
220229
hi def link rustDecNumber rustNumber

0 commit comments

Comments
 (0)