codekingpro/portable-devtools
115k
1" Vim syntax file2" Language: C++3" Maintainer: This runtime file is looking for a new maintainer.4" Previous Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp)5" Ken Shan <ccshan@post.harvard.edu>6" Last Change: 2024 May 047" 2024 May 04 by Vim Project fix digit separator in octals and floats8" 2026 Jan 06 by Vim Project orphaning announcement9" 2026 Jan 08 by Vim Project highlight capital letter prefixes for numbers10 11" quit when a syntax file was already loaded12if exists("b:current_syntax")13 finish14endif15 16" inform C syntax that the file was included from cpp.vim17let b:filetype_in_cpp_family = 118 19" Read the C syntax to start with20runtime! syntax/c.vim21unlet b:current_syntax22unlet b:filetype_in_cpp_family23 24" C++ extensions25syn keyword cppStatement new delete this friend using26syn keyword cppAccess public protected private27syn keyword cppModifier inline virtual explicit export28syn keyword cppType bool wchar_t29syn keyword cppExceptions throw try catch30syn keyword cppOperator operator typeid31syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq32syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*<"me=e-133syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$"34syn keyword cppStorageClass mutable35syn keyword cppStructure class typename template namespace36syn keyword cppBoolean true false37syn keyword cppConstant __cplusplus38 39" C++ 11 extensions40if !exists("cpp_no_cpp11")41 syn keyword cppModifier override final42 syn keyword cppType nullptr_t auto43 syn keyword cppExceptions noexcept44 syn keyword cppStorageClass constexpr decltype thread_local45 syn keyword cppConstant nullptr46 syn keyword cppConstant ATOMIC_FLAG_INIT ATOMIC_VAR_INIT47 syn keyword cppConstant ATOMIC_BOOL_LOCK_FREE ATOMIC_CHAR_LOCK_FREE48 syn keyword cppConstant ATOMIC_CHAR16_T_LOCK_FREE ATOMIC_CHAR32_T_LOCK_FREE49 syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE50 syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE51 syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE52 syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"\(sv\|s\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=+ contains=@Spell53 syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*<"me=e-154 syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*$"55endif56 57" C++ 14 extensions58if !exists("cpp_no_cpp14")59 syn match cppNumbers display transparent "\<\d\|\.\d" contains=cppNumber,cppFloat60 syn match cppNumber display contained "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"61 syn match cppNumber display contained "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"62 syn match cppNumber display contained "\<0\('\=\o\+\)\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"63 syn match cppNumber display contained "\<0[Bb][01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"64 syn match cppNumber display contained "\<0[Xx]\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"65 syn match cppFloat display contained "\<\d\('\=\d\+\)*\.\(\d\('\=\d\+\)*\)\=\([Ee][-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"66 syn match cppFloat display contained "\.\d\('\=\d\+\)*\([Ee][-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"67 syn match cppFloat display contained "\<\d\+[Ee][-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"68 syn region cppString start=+\(L\|u\|u8\|U\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell69endif70 71" C++ 17 extensions72if !exists("cpp_no_cpp17")73 syn match cppCast "\<reinterpret_pointer_cast\s*<"me=e-174 syn match cppCast "\<reinterpret_pointer_cast\s*$"75 syn match cppFloat display contained "\<0[Xx]\x*\.\x\+p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"76 syn match cppFloat display contained "\<0[Xx]\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"77 78 " TODO: push this up to c.vim if/when supported in C2379 syn match cppCharacter "u8'[^\\]'"80 syn match cppCharacter "u8'[^']*'" contains=cSpecial81 if exists("c_gnu")82 syn match cppSpecialError "u8'\\[^'\"?\\abefnrtv]'"83 syn match cppSpecialCharacter "u8'\\['\"?\\abefnrtv]'"84 else85 syn match cppSpecialError "u8'\\[^'\"?\\abfnrtv]'"86 syn match cppSpecialCharacter "u8'\\['\"?\\abfnrtv]'"87 endif88 syn match cppSpecialCharacter display "u8'\\\o\{1,3}'"89 syn match cppSpecialCharacter display "u8'\\x\x\+'"90 91endif92 93" C++ 20 extensions94if !exists("cpp_no_cpp20")95 syn match cppNumber display contained "\<0\(y\|d\)\>"96 syn match cppNumber display contained "\<[1-9]\('\=\d\+\)*\(y\|d\)\>"97 syn match cppNumber display contained "\<0\o\+\(y\|d\)\>"98 syn match cppNumber display contained "\<0[Bb][01]\('\=[01]\+\)*\(y\|d\)\>"99 syn match cppNumber display contained "\<0[Xx]\x\('\=\x\+\)*\(y\|d\)\>"100 syn keyword cppStatement co_await co_return co_yield requires101 syn keyword cppStorageClass consteval constinit102 syn keyword cppStructure concept103 syn keyword cppType char8_t104 syn keyword cppModule import module export105endif106 107" The minimum and maximum operators in GNU C++108syn match cppMinMax "[<>]?"109 110" Default highlighting111hi def link cppAccess cppStatement112hi def link cppCast cppStatement113hi def link cppExceptions Exception114hi def link cppOperator Operator115hi def link cppStatement Statement116hi def link cppModifier Type117hi def link cppType Type118hi def link cppStorageClass StorageClass119hi def link cppStructure Structure120hi def link cppBoolean Boolean121hi def link cppCharacter cCharacter122hi def link cppSpecialCharacter cSpecialCharacter123hi def link cppSpecialError cSpecialError124hi def link cppConstant Constant125hi def link cppRawStringDelimiter Delimiter126hi def link cppRawString String127hi def link cppString String128hi def link cppNumber Number129hi def link cppFloat Number130hi def link cppModule Include131 132let b:current_syntax = "cpp"133 134" vim: ts=8135 