Skip to content

Commit e651851

Browse files
committed
Highlight comments inside attributes.
Fixes #74.
1 parent 9924277 commit e651851

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

syntax/rust.vim

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: Patrick Walton <[email protected]>
44
" Maintainer: Ben Blum <[email protected]>
55
" Maintainer: Chris Morgan <[email protected]>
6-
" Last Change: January 29, 2015
6+
" Last Change: Feb 24, 2016
77

88
if version < 600
99
syntax clear
@@ -131,7 +131,7 @@ syn region rustString start=+b"+ skip=+\\\\\|\\"+ end=+"+ contains=rustE
131131
syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustStringContinuation,@Spell
132132
syn region rustString start='b\?r\z(#*\)"' end='"\z1' contains=@Spell
133133

134-
syn region rustAttribute start="#!\?\[" end="\]" contains=rustString,rustDerive
134+
syn region rustAttribute start="#!\?\[" end="\]" contains=rustString,rustDerive,rustCommentLine,rustCommentBlock,rustCommentLineDocError,rustCommentBlockDocError
135135
syn region rustDerive start="derive(" end=")" contained contains=rustDeriveTrait
136136
" This list comes from src/libsyntax/ext/deriving/mod.rs
137137
" Some are deprecated (Encodable, Decodable) or to be removed after a new snapshot (Show).
@@ -168,12 +168,15 @@ syn match rustCharacter /b'\([^\\]\|\\\(.\|x\x\{2}\)\)'/ contains=rustEscape
168168
syn match rustCharacter /'\([^\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\|u{\x\{1,6}}\)\)'/ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustCharacterInvalid
169169

170170
syn match rustShebang /\%^#![^[].*/
171-
syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell
172-
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell
173-
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell
174-
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell
175-
syn region rustCommentBlockNest matchgroup=rustCommentBlock start="/\*" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell contained transparent
176-
syn region rustCommentBlockDocNest matchgroup=rustCommentBlockDoc start="/\*" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell contained transparent
171+
syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell
172+
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell
173+
syn region rustCommentLineDocError start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell contained
174+
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell
175+
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell
176+
syn region rustCommentBlockDocError matchgroup=rustCommentBlockDocError start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNestError,@Spell contained
177+
syn region rustCommentBlockNest matchgroup=rustCommentBlock start="/\*" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell contained transparent
178+
syn region rustCommentBlockDocNest matchgroup=rustCommentBlockDoc start="/\*" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell contained transparent
179+
syn region rustCommentBlockDocNestError matchgroup=rustCommentBlockDocError start="/\*" end="\*/" contains=rustTodo,rustCommentBlockDocNestError,@Spell contained transparent
177180
" FIXME: this is a really ugly and not fully correct implementation. Most
178181
" importantly, a case like ``/* */*`` should have the final ``*`` not being in
179182
" a comment, but in practice at present it leaves comments open two levels
@@ -236,8 +239,10 @@ hi def link rustFuncCall Function
236239
hi def link rustShebang Comment
237240
hi def link rustCommentLine Comment
238241
hi def link rustCommentLineDoc SpecialComment
242+
hi def link rustCommentLineDocError Error
239243
hi def link rustCommentBlock rustCommentLine
240244
hi def link rustCommentBlockDoc rustCommentLineDoc
245+
hi def link rustCommentBlockDocError Error
241246
hi def link rustAssert PreCondit
242247
hi def link rustPanic PreCondit
243248
hi def link rustMacro Macro

0 commit comments

Comments
 (0)