about summary refs log tree commit diff
path: root/src/etc/vim/ftplugin
diff options
context:
space:
mode:
authorChris Morgan <me@chrismorgan.info>2013-07-10 09:56:08 +1000
committerDaniel Micay <danielmicay@gmail.com>2013-07-11 14:38:24 -0400
commit1d08ceb0439e1d09cb2285578872df53ad7eeb8c (patch)
tree93395aa333cc1c68cccb04113182e885473c2c92 /src/etc/vim/ftplugin
parent00da76dfbe3aba8c1ec399ecfa0eae4b4ba6885e (diff)
downloadrust-1d08ceb0439e1d09cb2285578872df53ad7eeb8c.tar.gz
rust-1d08ceb0439e1d09cb2285578872df53ad7eeb8c.zip
Fix comment indenting properly for Vim files.
Indentation now works correctly on subsequent lines of a multi-line
comment, whether there are leaders (` * `) or not. (Formerly it was
incorrectly doing a two-space indent if there was no leader.)

By default, this no longer puts a ` * ` leader on `/*!` comments, as
that appears to be the current convention in the Rust source code, but
that can easily be re-enabled if desired:

    let g:rust_bang_comment_leader = 1
Diffstat (limited to 'src/etc/vim/ftplugin')
-rw-r--r--src/etc/vim/ftplugin/rust.vim15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/etc/vim/ftplugin/rust.vim b/src/etc/vim/ftplugin/rust.vim
index f329dd6ce02..063b1152cb2 100644
--- a/src/etc/vim/ftplugin/rust.vim
+++ b/src/etc/vim/ftplugin/rust.vim
@@ -1,14 +1,25 @@
 " Vim syntax file
 " Language:     Rust
 " Maintainer:   Chris Morgan <me@chrismorgan.info>
-" Last Change:  2013 Jul 6
+" Last Change:  2013 Jul 10
 
 if exists("b:did_ftplugin")
 	finish
 endif
 let b:did_ftplugin = 1
 
-setlocal comments=s1:/*,mb:*,ex:*/,:///,://!,://
+" The rust source code at present seems to typically omit a leader on /*!
+" comments, so we'll use that as our default, but make it easy to switch.
+" This does not affect indentation at all (I tested it with and without
+" leader), merely whether a leader is inserted by default or not.
+if exists("g:rust_bang_comment_leader") && g:rust_bang_comment_leader == 1
+	" Why is the `,s0:/*,mb:\ ,ex:*/` there, you ask? I don't understand why,
+	" but without it, */ gets indented one space even if there were no
+	" leaders. I'm fairly sure that's a Vim bug.
+	setlocal comments=s1:/*,mb:*,ex:*/,s0:/*,mb:\ ,ex:*/,:///,://!,://
+else
+	setlocal comments=s0:/*!,m:\ ,ex:*/,s1:/*,mb:*,ex:*/,:///,://!,://
+endif
 setlocal commentstring=//%s
 setlocal formatoptions-=t formatoptions+=croqnlj