]> git.lizzy.rs Git - rust.git/commitdiff
A few slight tweaks to the Vim syntax file.
authorChris Morgan <me@chrismorgan.info>
Tue, 9 Jul 2013 15:27:35 +0000 (01:27 +1000)
committerChris Morgan <me@chrismorgan.info>
Tue, 9 Jul 2013 15:27:35 +0000 (01:27 +1000)
- Add fold support (NOT turned on by default)
- Highlight `::` by default
- Support the common `NOTE` as an important note
- Highlight `assert!` and `fail!` differently
- Don't highlight `deriving(...)` except in `#[...]`

src/etc/vim/syntax/rust.vim

index f40bed8640dce16e2f0d46475a0e1c3c6f3eedc0..dfcdb11e7682a9aec9932707fe631c0ed35d8b14 100644 (file)
@@ -2,7 +2,8 @@
 " Language:     Rust
 " Maintainer:   Patrick Walton <pcwalton@mozilla.com>
 " Maintainer:   Ben Blum <bblum@cs.cmu.edu>
-" Last Change:  2013 Jun 14
+" Maintainer:   Chris Morgan <me@chrismorgan.info>
+" Last Change:  2013 Jul 10
 
 if version < 600
   syntax clear
@@ -13,8 +14,8 @@ endif
 syn keyword   rustConditional match if else
 syn keyword   rustOperator    as
 
-syn match     rustAssert      "\<assert\(\w\)*!"
-syn match     rustFail        "\<fail\(\w\)*!"
+syn match     rustAssert      "\<assert\(\w\)*!" contained
+syn match     rustFail        "\<fail\(\w\)*!" contained
 syn keyword   rustKeyword     break copy do extern
 syn keyword   rustKeyword     for if impl let log
 syn keyword   rustKeyword     copy do extern
@@ -90,7 +91,7 @@ syn match     rustFormat      display "%%" contained
 syn region    rustString      start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=rustTodo,rustFormat
 
 syn region    rustAttribute   start="#\[" end="\]" contains=rustString,rustDeriving
-syn region    rustDeriving    start="deriving(" end=")" contains=rustTrait
+syn region    rustDeriving    start="deriving(" end=")" contained contains=rustTrait
 
 " Number literals
 syn match     rustNumber      display "\<[0-9][0-9_]*\>"
@@ -116,13 +117,18 @@ syn match     rustFloat       display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9
 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    rustCommentDoc  start="/\*[\*!]" end="\*/"
-syn region    rustCommentDoc  start="//[/!]" skip="\\$" end="$" keepend
-syn match     rustComment     "/\*\*/"
-syn region    rustComment     start="/\*\([^\*!]\|$\)" end="\*/" contains=rustTodo
-syn region    rustComment     start="//\([^/!]\|$\)" skip="\\$" end="$" contains=rustTodo keepend
+syn region    rustComment     start="/\*" end="\*/" contains=rustTodo
+syn region    rustComment     start="//" skip="\\$" end="$" contains=rustTodo keepend
+syn region    rustCommentDoc  start="/\*\%(!\|\*/\@!\)" end="\*/" contains=rustTodo
+syn region    rustCommentDoc  start="//[/!]" skip="\\$" end="$" contains=rustTodo keepend
 
-syn keyword rustTodo contained TODO FIXME XXX NB
+syn keyword rustTodo contained TODO FIXME XXX NB NOTE
+
+" Trivial folding rules to begin with.
+" TODO: use the AST to make really good folding
+syn region rustFoldBraces start="{" end="}" transparent fold
+" If you wish to enable this, setlocal foldmethod=syntax
+" It's not enabled by default as it would drive some people mad.
 
 hi def link rustHexNumber       rustNumber
 hi def link rustBinNumber       rustNumber
@@ -142,10 +148,13 @@ hi def link rustKeyword       Keyword
 hi def link rustConditional   Conditional
 hi def link rustIdentifier    Identifier
 hi def link rustModPath       Include
+hi def link rustModPathSep    Delimiter
 hi def link rustFuncName      Function
 hi def link rustFuncCall      Function
 hi def link rustCommentDoc    SpecialComment
 hi def link rustComment       Comment
+hi def link rustAssert        PreCondit
+hi def link rustFail          PreCondit
 hi def link rustMacro         Macro
 hi def link rustType          Type
 hi def link rustTodo          Todo
@@ -160,7 +169,6 @@ hi def link rustLifetime      Special
 " hi rustAssert ctermfg=yellow
 " hi rustFail ctermfg=red
 " hi rustMacro ctermfg=magenta
-" hi rustModPathSep ctermfg=grey
 
 syn sync minlines=200
 syn sync maxlines=500