Skip to content

Commit 7f37877

Browse files
rhysdda-x
authored andcommitted
highlight for keyword contextually
1 parent e99f3f5 commit 7f37877

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

syntax/rust.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ endif
1515
" Syntax definitions {{{1
1616
" Basic keywords {{{2
1717
syn keyword rustConditional match if else
18-
syn keyword rustRepeat for loop while
18+
syn keyword rustRepeat loop while
19+
" `:syn match` must be used to prioritize highlighting `for` keyword.
20+
syn match rustRepeat /\<for\>/
21+
" Highlight `for` keyword in `impl ... for ... {}` statement. This line must
22+
" be put after previous `syn match` line to overwrite it.
23+
syn match rustKeyword /\%(\<impl\>.\+\)\@<=\<for\>/
1924
syn keyword rustTypedef type nextgroup=rustIdentifier skipwhite skipempty
2025
syn keyword rustStructure struct enum nextgroup=rustIdentifier skipwhite skipempty
2126
syn keyword rustUnion union nextgroup=rustIdentifier skipwhite skipempty contained

0 commit comments

Comments
 (0)