Skip to content

Commit 4d7c1b4

Browse files
committed
Support shebangs.
Very few people know about this (I had even forgotten about it until a discussion on the subject in #rust just now, though I did know once), but rustc does actually explicitly allow shebangs as a form of comment.
1 parent 93e3e1d commit 4d7c1b4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

syntax/rust.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ syn match rustCharacterInvalidUnicode display contained /b'\zs[^[:cntrl:][:g
168168
syn match rustCharacter /b'\([^\\]\|\\\(.\|x\x\{2}\)\)'/ contains=rustEscape,rustEscapeError,rustCharacterInvalid,rustCharacterInvalidUnicode
169169
syn match rustCharacter /'\([^\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\|u{\x\{1,6}}\)\)'/ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustCharacterInvalid
170170

171+
syn match rustShebang /\%^#![^[].*/
171172
syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell
172173
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell
173174
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell
@@ -233,6 +234,7 @@ hi def link rustModPathSep Delimiter
233234
hi def link rustFunction Function
234235
hi def link rustFuncName Function
235236
hi def link rustFuncCall Function
237+
hi def link rustShebang Comment
236238
hi def link rustCommentLine Comment
237239
hi def link rustCommentLineDoc SpecialComment
238240
hi def link rustCommentBlock rustCommentLine

0 commit comments

Comments
 (0)