Skip to content

Commit 1b04be6

Browse files
committed
auto merge of #5049 : bstrie/rust/vim, r=catamorphism
1. Highlight new lifetime syntax 2. Visually distinguish `unsafe` keyword 3. Add a new file that highlights column 78, to warn when lines get too long
2 parents 8f8f0ec + e29b7ee commit 1b04be6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/etc/vim/after/ftplugin/rust.vim

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"Highlight the 78th text column
2+
"Feature became available in v7.3
3+
if version >= 703
4+
set colorcolumn=78
5+
endif

src/etc/vim/syntax/rust.vim

+5-1
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@ syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\(f\|f32\|f64\)\>
103103
syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\>"
104104
syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\(f\|f32\|f64\)\>"
105105

106+
"rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting
107+
syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
106108
syn match rustCharacter "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'"
107109

108110
syn region rustComment start="/\*" end="\*/" contains=rustComment,rustTodo
109111
syn region rustComment start="//" skip="\\$" end="$" contains=rustTodo keepend
110112

111-
syn keyword rustTodo TODO FIXME XXX NB
113+
114+
syn keyword rustTodo TODO FIXME XXX NB unsafe
112115

113116
hi def link rustHexNumber rustNumber
114117
hi def link rustBinNumber rustNumber
@@ -134,6 +137,7 @@ hi def link rustType Type
134137
hi def link rustTodo Todo
135138
hi def link rustAttribute PreProc
136139
hi def link rustStorage StorageClass
140+
hi def link rustLifetime Special
137141

138142
" Other Suggestions:
139143
" hi rustAssert ctermfg=yellow

0 commit comments

Comments
 (0)