Skip to content

Commit 4914992

Browse files
committed
Add syntax support for u8 character literals
1 parent 0493ae5 commit 4914992

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

syntax/cpp.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ if !exists("cpp_no_cpp17")
6969
syn match cppCast "\<reinterpret_pointer_cast\s*$"
7070
syn match cppFloat display contained "\<0x\x*\.\x\+p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
7171
syn match cppFloat display contained "\<0x\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
72+
73+
" TODO: push this up to c.vim if/when supported in C23
74+
syn match cppCharacter "u8'[^\\]'"
75+
syn match cppCharacter "u8'[^']*'" contains=cSpecial
76+
if exists("c_gnu")
77+
syn match cppSpecialError "u8'\\[^'\"?\\abefnrtv]'"
78+
syn match cppSpecialCharacter "u8'\\['\"?\\abefnrtv]'"
79+
else
80+
syn match cppSpecialError "u8'\\[^'\"?\\abfnrtv]'"
81+
syn match cppSpecialCharacter "u8'\\['\"?\\abfnrtv]'"
82+
endif
83+
syn match cppSpecialCharacter display "u8'\\\o\{1,3}'"
84+
syn match cppSpecialCharacter display "u8'\\x\x\+'"
85+
7286
endif
7387

7488
" C++ 20 extensions
@@ -99,6 +113,9 @@ hi def link cppType Type
99113
hi def link cppStorageClass StorageClass
100114
hi def link cppStructure Structure
101115
hi def link cppBoolean Boolean
116+
hi def link cppCharacter cCharacter
117+
hi def link cppSpecialCharacter cSpecialCharacter
118+
hi def link cppSpecialError cSpecialError
102119
hi def link cppConstant Constant
103120
hi def link cppRawStringDelimiter Delimiter
104121
hi def link cppRawString String

0 commit comments

Comments
 (0)