about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBen Striegel <ben.striegel@gmail.com>2013-02-19 23:07:09 -0500
committerBen Striegel <ben.striegel@gmail.com>2013-02-19 23:07:09 -0500
commite29b7eedf9670e2a86647b318f6cb9c2a8a46463 (patch)
treef535e4e468149484fe615954cacbfc6a916fd362
parentb88e4f3b9f5331a3159c754fa17f906a827ef6fd (diff)
downloadrust-e29b7eedf9670e2a86647b318f6cb9c2a8a46463.tar.gz
rust-e29b7eedf9670e2a86647b318f6cb9c2a8a46463.zip
vim improvements
1. Highlight new lifetime syntax
2. Visually distinguish `unsafe` keyword
3. Add a new file that highlights column 78, to warn when lines get too long
-rw-r--r--src/etc/vim/after/ftplugin/rust.vim5
-rw-r--r--src/etc/vim/syntax/rust.vim6
2 files changed, 10 insertions, 1 deletions
diff --git a/src/etc/vim/after/ftplugin/rust.vim b/src/etc/vim/after/ftplugin/rust.vim
new file mode 100644
index 00000000000..56616de6aa8
--- /dev/null
+++ b/src/etc/vim/after/ftplugin/rust.vim
@@ -0,0 +1,5 @@
+"Highlight the 78th text column
+"Feature became available in v7.3
+if version >= 703
+    set colorcolumn=78
+endif
diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim
index 8893608cda6..f811fbf5855 100644
--- a/src/etc/vim/syntax/rust.vim
+++ b/src/etc/vim/syntax/rust.vim
@@ -103,12 +103,15 @@ syn match     rustFloat       display "\<[0-9][0-9_]*\.[0-9_]\+\(f\|f32\|f64\)\>
 syn match     rustFloat       display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\>"
 syn match     rustFloat       display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\(f\|f32\|f64\)\>"
 
+"rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting
+syn match     rustLifetime    display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
 syn match   rustCharacter   "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'"
 
 syn region    rustComment     start="/\*" end="\*/" contains=rustComment,rustTodo
 syn region    rustComment     start="//" skip="\\$" end="$" contains=rustTodo keepend
 
-syn keyword   rustTodo        TODO FIXME XXX NB
+
+syn keyword   rustTodo        TODO FIXME XXX NB unsafe
 
 hi def link rustHexNumber       rustNumber
 hi def link rustBinNumber       rustNumber
@@ -134,6 +137,7 @@ hi def link rustType          Type
 hi def link rustTodo          Todo
 hi def link rustAttribute     PreProc
 hi def link rustStorage       StorageClass
+hi def link rustLifetime      Special
 
 " Other Suggestions:
 " hi rustAssert ctermfg=yellow