From 491499215044ce4b08eb15dca36b0fd70b5cf075 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Mon, 23 Aug 2021 22:44:10 +1000 Subject: [PATCH 1/2] Add syntax support for u8 character literals --- syntax/cpp.vim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 3ad79d5..42709df 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -69,6 +69,20 @@ if !exists("cpp_no_cpp17") syn match cppCast "\" syn match cppFloat display contained "\<0x\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + + " TODO: push this up to c.vim if/when supported in C23 + syn match cppCharacter "u8'[^\\]'" + syn match cppCharacter "u8'[^']*'" contains=cSpecial + if exists("c_gnu") + syn match cppSpecialError "u8'\\[^'\"?\\abefnrtv]'" + syn match cppSpecialCharacter "u8'\\['\"?\\abefnrtv]'" + else + syn match cppSpecialError "u8'\\[^'\"?\\abfnrtv]'" + syn match cppSpecialCharacter "u8'\\['\"?\\abfnrtv]'" + endif + syn match cppSpecialCharacter display "u8'\\\o\{1,3}'" + syn match cppSpecialCharacter display "u8'\\x\x\+'" + endif " C++ 20 extensions @@ -99,6 +113,9 @@ hi def link cppType Type hi def link cppStorageClass StorageClass hi def link cppStructure Structure hi def link cppBoolean Boolean +hi def link cppCharacter cCharacter +hi def link cppSpecialCharacter cSpecialCharacter +hi def link cppSpecialError cSpecialError hi def link cppConstant Constant hi def link cppRawStringDelimiter Delimiter hi def link cppRawString String From e955eeb11f328b4bddbfa66527fe9da1af99990b Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Mon, 23 Aug 2021 22:46:24 +1000 Subject: [PATCH 2/2] Whitespace fixes --- syntax/cpp.vim | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 42709df..03f9eb9 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -103,26 +103,26 @@ endif syn match cppMinMax "[<>]?" " Default highlighting -hi def link cppAccess cppStatement -hi def link cppCast cppStatement +hi def link cppAccess cppStatement +hi def link cppCast cppStatement hi def link cppExceptions Exception -hi def link cppOperator Operator +hi def link cppOperator Operator hi def link cppStatement Statement -hi def link cppModifier Type -hi def link cppType Type -hi def link cppStorageClass StorageClass +hi def link cppModifier Type +hi def link cppType Type +hi def link cppStorageClass StorageClass hi def link cppStructure Structure -hi def link cppBoolean Boolean -hi def link cppCharacter cCharacter -hi def link cppSpecialCharacter cSpecialCharacter -hi def link cppSpecialError cSpecialError -hi def link cppConstant Constant +hi def link cppBoolean Boolean +hi def link cppCharacter cCharacter +hi def link cppSpecialCharacter cSpecialCharacter +hi def link cppSpecialError cSpecialError +hi def link cppConstant Constant hi def link cppRawStringDelimiter Delimiter hi def link cppRawString String -hi def link cppString String -hi def link cppNumber Number -hi def link cppFloat Number -hi def link cppModule Include +hi def link cppString String +hi def link cppNumber Number +hi def link cppFloat Number +hi def link cppModule Include let b:current_syntax = "cpp"