1" Vim syntax file 2" Language: C++ 3" Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) 4" Previous Maintainer: Ken Shan <[email protected]> 5" Last Change: 2021 May 04 6 7" quit when a syntax file was already loaded 8if exists("b:current_syntax") 9 finish 10endif 11 12" inform C syntax that the file was included from cpp.vim 13let b:filetype_in_cpp_family = 1 14 15" Read the C syntax to start with 16runtime! syntax/c.vim 17unlet b:current_syntax 18 19" C++ extensions 20syn keyword cppStatement new delete this friend using 21syn keyword cppAccess public protected private 22syn keyword cppModifier inline virtual explicit export 23syn keyword cppType bool wchar_t 24syn keyword cppExceptions throw try catch 25syn keyword cppOperator operator typeid 26syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq 27syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*<"me=e-1 28syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$" 29syn keyword cppStorageClass mutable 30syn keyword cppStructure class typename template namespace 31syn keyword cppBoolean true false 32syn keyword cppConstant __cplusplus 33 34" C++ 11 extensions 35if !exists("cpp_no_cpp11") 36 syn keyword cppModifier override final 37 syn keyword cppType nullptr_t auto 38 syn keyword cppExceptions noexcept 39 syn keyword cppStorageClass constexpr decltype thread_local 40 syn keyword cppConstant nullptr 41 syn keyword cppConstant ATOMIC_FLAG_INIT ATOMIC_VAR_INIT 42 syn keyword cppConstant ATOMIC_BOOL_LOCK_FREE ATOMIC_CHAR_LOCK_FREE 43 syn keyword cppConstant ATOMIC_CHAR16_T_LOCK_FREE ATOMIC_CHAR32_T_LOCK_FREE 44 syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE 45 syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE 46 syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE 47 syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"\(sv\|s\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=+ contains=@Spell 48 syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*<"me=e-1 49 syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*$" 50endif 51 52" C++ 14 extensions 53if !exists("cpp_no_cpp14") 54 syn match cppNumbers display transparent "\<\d\|\.\d" contains=cppNumber,cppFloat 55 syn match cppNumber display contained "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 56 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*\)\=\>" 57 syn match cppNumber display contained "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 58 syn match cppNumber display contained "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 59 syn match cppNumber display contained "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 60 syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 61 syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 62 syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 63 syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell 64endif 65 66" C++ 17 extensions 67if !exists("cpp_no_cpp17") 68 syn match cppCast "\<reinterpret_pointer_cast\s*<"me=e-1 69 syn match cppCast "\<reinterpret_pointer_cast\s*$" 70 syn match cppFloat display contained "\<0x\x*\.\x\+p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 71 syn match cppFloat display contained "\<0x\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 72endif 73 74" C++ 20 extensions 75if !exists("cpp_no_cpp20") 76 syn match cppNumber display contained "\<0\(y\|d\)\>" 77 syn match cppNumber display contained "\<[1-9]\('\=\d\+\)*\(y\|d\)\>" 78 syn match cppNumber display contained "\<0\o\+\(y\|d\)\>" 79 syn match cppNumber display contained "\<0b[01]\('\=[01]\+\)*\(y\|d\)\>" 80 syn match cppNumber display contained "\<0x\x\('\=\x\+\)*\(y\|d\)\>" 81 syn keyword cppStatement co_await co_return co_yield requires 82 syn keyword cppStorageClass consteval constinit 83 syn keyword cppStructure concept 84 syn keyword cppType char8_t 85 syn keyword cppModule import module export 86endif 87 88" The minimum and maximum operators in GNU C++ 89syn match cppMinMax "[<>]?" 90 91" Default highlighting 92hi def link cppAccess cppStatement 93hi def link cppCast cppStatement 94hi def link cppExceptions Exception 95hi def link cppOperator Operator 96hi def link cppStatement Statement 97hi def link cppModifier Type 98hi def link cppType Type 99hi def link cppStorageClass StorageClass 100hi def link cppStructure Structure 101hi def link cppBoolean Boolean 102hi def link cppConstant Constant 103hi def link cppRawStringDelimiter Delimiter 104hi def link cppRawString String 105hi def link cppString String 106hi def link cppNumber Number 107hi def link cppFloat Number 108hi def link cppModule Include 109 110let b:current_syntax = "cpp" 111 112" vim: ts=8 113