Set softtabstop, textwidth, and optionally colorcolumn

Setting softtabstop makes <Del> delete 4 spaces as if it were a tab.

Setting textwidth allows comments to be wrapped automatically. It's set
at 80, which is the recommended line length for Rust programs. There are
suggestions that it should be 79, but our current style guide says 80 so
that's what we're matching.

A new setting g:rust_colorcolumn sets colorcolumn as well, to +1,101.
This indicates both the textwidth and the second stricter line length of
100 that our style guide lists.
This commit is contained in:
Kevin Ballard 2014-07-06 01:09:03 -07:00
parent c6492040b2
commit 94cfd1b4ad
2 changed files with 32 additions and 4 deletions

View File

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

View File

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