Skip to content

Commit bc35eb7

Browse files
committed
vim: Tweak how comment nesting works
Don't try to match line comments inside of a comment block. That makes no sense and can highlight differently for people who override their highlights. Similarly, don't match a doc-comment inside of a comment block. It shouldn't be highlighted differently unless it's actually a doc-comment (and nested comments are obviously not doc comments). Fixes #12307.
1 parent d98668a commit bc35eb7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/etc/vim/syntax/rust.vim

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,12 @@ syn region rustGenericLifetimeCandidate display start=/\%(<\|,\s*\)\@<='/ end=/[
178178
syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
179179
syn match rustCharacter /'\([^'\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'/ contains=rustSpecial,rustSpecialError
180180

181-
syn cluster rustComment contains=rustCommentLine,rustCommentLineDoc,rustCommentBlock,rustCommentBlockDoc
182-
syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell
183-
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell
184-
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,@rustComment,@Spell keepend extend
185-
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,@rustComment,@Spell keepend extend
181+
syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell
182+
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell
183+
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell
184+
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell
185+
syn region rustCommentBlockNest matchgroup=rustCommentBlock start="/\*" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell contained transparent
186+
syn region rustCommentBlockDocNest matchgroup=rustCommentBlockDoc start="/\*" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell contained transparent
186187
" FIXME: this is a really ugly and not fully correct implementation. Most
187188
" importantly, a case like ``/* */*`` should have the final ``*`` not being in
188189
" a comment, but in practice at present it leaves comments open two levels

0 commit comments

Comments
 (0)