" 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
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
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_]*\>"
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
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
" hi rustAssert ctermfg=yellow
" hi rustFail ctermfg=red
" hi rustMacro ctermfg=magenta
-" hi rustModPathSep ctermfg=grey
syn sync minlines=200
syn sync maxlines=500