about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/etc/vim/doc/rust.txt8
-rw-r--r--src/etc/vim/ftplugin/rust.vim28
2 files changed, 32 insertions, 4 deletions
diff --git a/src/etc/vim/doc/rust.txt b/src/etc/vim/doc/rust.txt
index 15b231df8fe..fdf3a052b2c 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|
@@ -34,6 +34,12 @@ g:rustc_makeprg_no_percent~
 	    let g:rustc_makeprg_no_percent = 1
 <
 
+                                                          *g:rust_colorcolumn*
+g:rust_colorcolumn~
+	Set this option to use 'colorcolumn' to highlight the text width
+	indicate the 100 column recommended hard limit on line lengths: >
+	    let g:rust_colorcolumn = 1
+<
                                                               *g:rust_conceal*
 g:rust_conceal~
 	Set this option to turn on the basic |conceal| support: >
diff --git a/src/etc/vim/ftplugin/rust.vim b/src/etc/vim/ftplugin/rust.vim
index 16ed43415c3..2b1261c35b5 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 <me@chrismorgan.info>
 " Maintainer:   Kevin Ballard <kevin@sb.org>
-" Last Change:  May 27, 2014
+" Last Change:  July 06, 2014
 
 if exists("b:did_ftplugin")
 	finish
@@ -35,7 +35,24 @@ 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
+
+" Line lengths {{{2
+
+" Rust style conventions for line lengths say you SHOULD not go over 80
+" columns and MUST not go over 100.
+" Without a good 'formatexpr' we can't automatically wrap code, but we can
+" still wrap comments just fine with 'textwidth'.
+setlocal textwidth=80
+
+" We can also use 'colorcolumn' to highlight both the 80 and 100 limits. Not
+" everyone likes this so it's gated.
+if exists('g:rust_colorcolumn')
+	setlocal colorcolumn=+1,101
+	let b:rust_colorcolumn=1
+endif
+
+" }}}2
 
 " This includeexpr isn't perfect, but it's a good start
 setlocal includeexpr=substitute(v:fname,'::','/','g')
@@ -93,7 +110,12 @@ 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_colorcolumn')
+		  \|setlocal colorcolumn<
+		  \|unlet b:rust_colorcolumn
+		\|endif
 		\|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