From 3fa4cef876714db93ba64b8e1166f21775f99a29 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 10 Jul 2013 01:27:35 +1000 Subject: [PATCH] A few slight tweaks to the Vim syntax file. - 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 | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index f40bed8640d..dfcdb11e768 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -2,7 +2,8 @@ " Language: Rust " Maintainer: Patrick Walton " Maintainer: Ben Blum -" Last Change: 2013 Jun 14 +" Maintainer: Chris Morgan +" 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 "\" @@ -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