Skip to content

Commit b52c13a

Browse files
authored
Merge pull request vim-jp#60 from dkearns/add-support-for-u8-character-literal
Add support for u8 character literals
2 parents 5a6e17f + e955eeb commit b52c13a

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

syntax/cpp.vim

+29-12
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
@@ -89,23 +103,26 @@ endif
89103
syn match cppMinMax "[<>]?"
90104

91105
" Default highlighting
92-
hi def link cppAccess cppStatement
93-
hi def link cppCast cppStatement
106+
hi def link cppAccess cppStatement
107+
hi def link cppCast cppStatement
94108
hi def link cppExceptions Exception
95-
hi def link cppOperator Operator
109+
hi def link cppOperator Operator
96110
hi def link cppStatement Statement
97-
hi def link cppModifier Type
98-
hi def link cppType Type
99-
hi def link cppStorageClass StorageClass
111+
hi def link cppModifier Type
112+
hi def link cppType Type
113+
hi def link cppStorageClass StorageClass
100114
hi def link cppStructure Structure
101-
hi def link cppBoolean Boolean
102-
hi def link cppConstant Constant
115+
hi def link cppBoolean Boolean
116+
hi def link cppCharacter cCharacter
117+
hi def link cppSpecialCharacter cSpecialCharacter
118+
hi def link cppSpecialError cSpecialError
119+
hi def link cppConstant Constant
103120
hi def link cppRawStringDelimiter Delimiter
104121
hi def link cppRawString String
105-
hi def link cppString String
106-
hi def link cppNumber Number
107-
hi def link cppFloat Number
108-
hi def link cppModule Include
122+
hi def link cppString String
123+
hi def link cppNumber Number
124+
hi def link cppFloat Number
125+
hi def link cppModule Include
109126

110127
let b:current_syntax = "cpp"
111128

0 commit comments

Comments
 (0)