diff options
| author | Kevin Ballard <kevin@sb.org> | 2014-05-20 14:11:07 -0700 |
|---|---|---|
| committer | Kevin Ballard <kevin@sb.org> | 2014-05-20 15:06:53 -0700 |
| commit | bf0c6d8166b1b1a3c45a3131a6f019ed8a005a1f (patch) | |
| tree | cab88f4674fb95bb3b335a7f50b398c048b58eb0 | |
| parent | 229338d6ac6b9252ecdb923ffc1ec0d71e3145d5 (diff) | |
| download | rust-bf0c6d8166b1b1a3c45a3131a6f019ed8a005a1f.tar.gz rust-bf0c6d8166b1b1a3c45a3131a6f019ed8a005a1f.zip | |
vim: Handle box expressions specially
Attempt to highlight the placement expression in a `box (expr) foo` expression. Also treat GC as a keyword within the placement expression. This doesn't work correctly for arbitrary expressions. Notably, this makes no attempt at balancing delimiters. I believe handling that will require rewriting the syntax rules to add a region for every pair of delimiters. That may be a desirable thing to do in the end, because we can then rewrite our indent rules based on the syntax and get rid of cindent(), but for the time being, we'll just live with the limitation.
| -rw-r--r-- | src/etc/vim/syntax/rust.vim | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index c9ad39a83dc..29e597589d2 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -18,27 +18,38 @@ syn keyword rustOperator as syn match rustAssert "\<assert\(\w\)*!" contained syn match rustFail "\<fail\(\w\)*!" contained -syn keyword rustKeyword break box continue -syn keyword rustKeyword extern nextgroup=rustExternCrate,rustObsoleteExternMod skipwhite +syn keyword rustKeyword break +syn keyword rustKeyword box nextgroup=rustBoxPlacement skipwhite skipempty +syn keyword rustKeyword continue +syn keyword rustKeyword extern nextgroup=rustExternCrate,rustObsoleteExternMod skipwhite skipempty +syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite skipempty syn keyword rustKeyword for in if impl let syn keyword rustKeyword loop once proc pub syn keyword rustKeyword return super syn keyword rustKeyword unsafe virtual while -syn keyword rustKeyword use nextgroup=rustModPath skipwhite +syn keyword rustKeyword use nextgroup=rustModPath skipwhite skipempty " FIXME: Scoped impl's name is also fallen in this category -syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite -syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite +syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite skipempty syn keyword rustStorage mut ref static syn keyword rustObsoleteStorage const syn keyword rustInvalidBareKeyword crate -syn keyword rustExternCrate crate contained nextgroup=rustIdentifier skipwhite -syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite +syn keyword rustExternCrate crate contained nextgroup=rustIdentifier skipwhite skipempty +syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite skipempty syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained +syn region rustBoxPlacement matchgroup=rustBoxPlacementParens start="(" end=")" contains=TOP contained +syn keyword rustBoxPlacementExpr GC containedin=rustBoxPlacement +" Ideally we'd have syntax rules set up to match arbitrary expressions. Since +" we don't, we'll just define temporary contained rules to handle balancing +" delimiters. +syn region rustBoxPlacementBalance start="(" end=")" containedin=rustBoxPlacement transparent +syn region rustBoxPlacementBalance start="\[" end="\]" containedin=rustBoxPlacement transparent +" {} are handled by rustFoldBraces + " Reserved (but not yet used) keywords {{{2 syn keyword rustReservedKeyword alignof be do offsetof priv pure sizeof typeof unsized yield @@ -244,6 +255,8 @@ hi def link rustLifetime Special hi def link rustInvalidBareKeyword Error hi def link rustExternCrate rustKeyword hi def link rustObsoleteExternMod Error +hi def link rustBoxPlacementParens Delimiter +hi def link rustBoxPlacementExpr rustKeyword " Other Suggestions: " hi rustAttribute ctermfg=cyan |
