Skip to content

Commit f530aa0

Browse files
committed
auto merge of #19095 : juxiliary/rust/master, r=bstrie
Vim plugins shouldn't override user settings unless they ask! Stops the plugin from modifying the users settings by default instead makes them opt-in with `g:rust_recommended_style`
2 parents 9efa23e + 62a2a1d commit f530aa0

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/etc/vim/doc/rust.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ g:rust_conceal_pub~
5353
let g:rust_conceal_pub = 1
5454
<
5555

56+
*g:rust_recommended_style*
57+
g:rust_recommended_style~
58+
Set this option to enable vim indentation and textwidth settings to
59+
conform to style conventions of the rust standard library (i.e. use 4
60+
spaces for indents and sets 'textwidth' to 99). This option is enabled
61+
by default. To disable it: >
62+
let g:rust_recommended_style = 0
63+
<
64+
5665
*g:rust_fold*
5766
g:rust_fold~
5867
Set this option to turn on |folding|: >

src/etc/vim/ftplugin/rust.vim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ silent! setlocal formatoptions+=j
3535
" otherwise it's better than nothing.
3636
setlocal smartindent nocindent
3737

38-
setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
39-
40-
setlocal textwidth=99
38+
if !exists("g:rust_recommended_style") || g:rust_recommended_style == 1
39+
setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
40+
setlocal textwidth=99
41+
endif
4142

4243
" This includeexpr isn't perfect, but it's a good start
4344
setlocal includeexpr=substitute(v:fname,'::','/','g')

0 commit comments

Comments
 (0)