├── README.mkd └── syntax ├── cpp.vim └── c.vim /README.mkd: -------------------------------------------------------------------------------- 1 | # vim-cpp 2 | 3 | This is Vim syntax files with C++11 support. `c.vim` is based on Bram Moolenaar 4 | and `cpp.vim` is based on Ken Shan . 5 | 6 | ## License 7 | 8 | License of original files conform to author of them. Enhancement of changes 9 | are licensed as VIM license. `vim-jp` will do maintenance of those files if 10 | possible. But we contribute this changes to VIM. 11 | -------------------------------------------------------------------------------- /syntax/cpp.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: C++ 3 | " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) 4 | " Previous Maintainer: Ken Shan 5 | " Last Change: 2021 May 04 6 | 7 | " quit when a syntax file was already loaded 8 | if exists("b:current_syntax") 9 | finish 10 | endif 11 | 12 | " inform C syntax that the file was included from cpp.vim 13 | let b:filetype_in_cpp_family = 1 14 | 15 | " Read the C syntax to start with 16 | runtime! syntax/c.vim 17 | unlet b:current_syntax 18 | 19 | " C++ extensions 20 | syn keyword cppStatement new delete this friend using 21 | syn keyword cppAccess public protected private 22 | syn keyword cppModifier inline virtual explicit export 23 | syn keyword cppType bool wchar_t 24 | syn keyword cppExceptions throw try catch 25 | syn keyword cppOperator operator typeid 26 | syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq 27 | syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*<"me=e-1 28 | syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$" 29 | syn keyword cppStorageClass mutable 30 | syn keyword cppStructure class typename template namespace 31 | syn keyword cppBoolean true false 32 | syn keyword cppConstant __cplusplus 33 | 34 | " C++ 11 extensions 35 | if !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*$" 50 | endif 51 | 52 | " C++ 14 extensions 53 | if !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 "\<0[bB][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 "\<0[xX]\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*\([eE][-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 61 | syn match cppFloat display contained "\<\.\d\+\([eE][-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 62 | syn match cppFloat display contained "\<\d\+[eE][-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" 63 | syn region cppString start=+\(L\|u\|u8\|U\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell 64 | endif 65 | 66 | " C++ 17 extensions 67 | if !exists("cpp_no_cpp17") 68 | syn match cppCast "\" 71 | syn match cppFloat display contained "\<0[xX]\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 | endif 86 | 87 | " C++ 20 extensions 88 | if !exists("cpp_no_cpp20") 89 | syn match cppNumber display contained "\<0\(y\|d\)\>" 90 | syn match cppNumber display contained "\<[1-9]\('\=\d\+\)*\(y\|d\)\>" 91 | syn match cppNumber display contained "\<0\o\+\(y\|d\)\>" 92 | syn match cppNumber display contained "\<0[bB][01]\('\=[01]\+\)*\(y\|d\)\>" 93 | syn match cppNumber display contained "\<0[xX]\x\('\=\x\+\)*\(y\|d\)\>" 94 | syn keyword cppStatement co_await co_return co_yield requires 95 | syn keyword cppStorageClass consteval constinit 96 | syn keyword cppStructure concept 97 | syn keyword cppType char8_t 98 | syn keyword cppModule import module export 99 | endif 100 | 101 | " The minimum and maximum operators in GNU C++ 102 | syn match cppMinMax "[<>]?" 103 | 104 | " Default highlighting 105 | hi def link cppAccess cppStatement 106 | hi def link cppCast cppStatement 107 | hi def link cppExceptions Exception 108 | hi def link cppOperator Operator 109 | hi def link cppStatement Statement 110 | hi def link cppModifier Type 111 | hi def link cppType Type 112 | hi def link cppStorageClass StorageClass 113 | hi def link cppStructure Structure 114 | hi def link cppBoolean Boolean 115 | hi def link cppCharacter cCharacter 116 | hi def link cppSpecialCharacter cSpecialCharacter 117 | hi def link cppSpecialError cSpecialError 118 | hi def link cppConstant Constant 119 | hi def link cppRawStringDelimiter Delimiter 120 | hi def link cppRawString String 121 | hi def link cppString String 122 | hi def link cppNumber Number 123 | hi def link cppFloat Number 124 | hi def link cppModule Include 125 | 126 | let b:current_syntax = "cpp" 127 | 128 | " vim: ts=8 129 | -------------------------------------------------------------------------------- /syntax/c.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: C 3 | " Maintainer: Bram Moolenaar 4 | " Last Change: 2021 May 24 5 | 6 | " Quit when a (custom) syntax file was already loaded 7 | if exists("b:current_syntax") 8 | finish 9 | endif 10 | 11 | let s:cpo_save = &cpo 12 | set cpo&vim 13 | 14 | let s:ft = matchstr(&ft, '^\([^.]\)\+') 15 | 16 | " check if this was included from cpp.vim 17 | let s:in_cpp_family = exists("b:filetype_in_cpp_family") 18 | 19 | " Optional embedded Autodoc parsing 20 | " To enable it add: let g:c_autodoc = 1 21 | " to your .vimrc 22 | if exists("c_autodoc") 23 | syn include @cAutodoc :p:h/autodoc.vim 24 | unlet b:current_syntax 25 | endif 26 | 27 | " A bunch of useful C keywords 28 | syn keyword cStatement goto break return continue asm 29 | syn keyword cLabel case default 30 | syn keyword cConditional if else switch 31 | syn keyword cRepeat while for do 32 | 33 | syn keyword cTodo contained TODO FIXME XXX 34 | 35 | " It's easy to accidentally add a space after a backslash that was intended 36 | " for line continuation. Some compilers allow it, which makes it 37 | " unpredictable and should be avoided. 38 | syn match cBadContinuation contained "\\\s\+$" 39 | 40 | " cCommentGroup allows adding matches for special things in comments 41 | syn cluster cCommentGroup contains=cTodo,cBadContinuation 42 | 43 | " String and Character constants 44 | " Highlight special characters (those which have a backslash) differently 45 | syn match cSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" 46 | if !exists("c_no_utf") 47 | syn match cSpecial display contained "\\\(u\x\{4}\|U\x\{8}\)" 48 | endif 49 | 50 | if !exists("c_no_cformat") 51 | " Highlight % items in strings. 52 | if !exists("c_no_c99") " ISO C99 53 | syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained 54 | else 55 | syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained 56 | endif 57 | syn match cFormat display "%%" contained 58 | endif 59 | 60 | " cCppString: same as cString, but ends at end of line 61 | if s:in_cpp_family && !exists("cpp_no_cpp11") && !exists("c_no_cformat") 62 | " ISO C++11 63 | syn region cString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend 64 | syn region cCppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell 65 | elseif s:ft ==# "c" && !exists("c_no_c11") && !exists("c_no_cformat") 66 | " ISO C99 67 | syn region cString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend 68 | syn region cCppString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell 69 | else 70 | " older C or C++ 71 | syn match cFormat display "%%" contained 72 | syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend 73 | syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell 74 | endif 75 | 76 | syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip 77 | 78 | syn cluster cStringGroup contains=cCppString,cCppSkip 79 | 80 | syn match cCharacter "L\='[^\\]'" 81 | syn match cCharacter "L'[^']*'" contains=cSpecial 82 | if exists("c_gnu") 83 | syn match cSpecialError "L\='\\[^'\"?\\abefnrtv]'" 84 | syn match cSpecialCharacter "L\='\\['\"?\\abefnrtv]'" 85 | else 86 | syn match cSpecialError "L\='\\[^'\"?\\abfnrtv]'" 87 | syn match cSpecialCharacter "L\='\\['\"?\\abfnrtv]'" 88 | endif 89 | syn match cSpecialCharacter display "L\='\\\o\{1,3}'" 90 | syn match cSpecialCharacter display "'\\x\x\{1,2}'" 91 | syn match cSpecialCharacter display "L'\\x\x\+'" 92 | 93 | if (s:ft ==# "c" && !exists("c_no_c11")) || (s:in_cpp_family && !exists("cpp_no_cpp11")) 94 | " ISO C11 or ISO C++ 11 95 | if exists("c_no_cformat") 96 | syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend 97 | else 98 | syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend 99 | endif 100 | syn match cCharacter "[Uu]'[^\\]'" 101 | syn match cCharacter "[Uu]'[^']*'" contains=cSpecial 102 | if exists("c_gnu") 103 | syn match cSpecialError "[Uu]'\\[^'\"?\\abefnrtv]'" 104 | syn match cSpecialCharacter "[Uu]'\\['\"?\\abefnrtv]'" 105 | else 106 | syn match cSpecialError "[Uu]'\\[^'\"?\\abfnrtv]'" 107 | syn match cSpecialCharacter "[Uu]'\\['\"?\\abfnrtv]'" 108 | endif 109 | syn match cSpecialCharacter display "[Uu]'\\\o\{1,3}'" 110 | syn match cSpecialCharacter display "[Uu]'\\x\x\+'" 111 | endif 112 | 113 | "when wanted, highlight trailing white space 114 | if exists("c_space_errors") 115 | if !exists("c_no_trail_space_error") 116 | syn match cSpaceError display excludenl "\s\+$" 117 | endif 118 | if !exists("c_no_tab_space_error") 119 | syn match cSpaceError display " \+\t"me=e-1 120 | endif 121 | endif 122 | 123 | " This should be before cErrInParen to avoid problems with #define ({ xxx }) 124 | if exists("c_curly_error") 125 | syn match cCurlyError "}" 126 | syn region cBlock start="{" end="}" contains=ALLBUT,cBadBlock,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell fold 127 | else 128 | syn region cBlock start="{" end="}" transparent fold 129 | endif 130 | 131 | " Catch errors caused by wrong parenthesis and brackets. 132 | " Also accept <% for {, %> for }, <: for [ and :> for ] (C99) 133 | " But avoid matching <::. 134 | syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom 135 | if exists("c_no_curly_error") 136 | if s:in_cpp_family && !exists("cpp_no_cpp11") 137 | syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell 138 | " cCppParen: same as cParen but ends at end-of-line; used in cDefine 139 | syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell 140 | syn match cParenError display ")" 141 | syn match cErrInParen display contained "^^<%\|^%>" 142 | else 143 | syn region cParen transparent start='(' end=')' contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell 144 | " cCppParen: same as cParen but ends at end-of-line; used in cDefine 145 | syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell 146 | syn match cParenError display ")" 147 | syn match cErrInParen display contained "^[{}]\|^<%\|^%>" 148 | endif 149 | elseif exists("c_no_bracket_error") 150 | if s:in_cpp_family && !exists("cpp_no_cpp11") 151 | syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell 152 | " cCppParen: same as cParen but ends at end-of-line; used in cDefine 153 | syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell 154 | syn match cParenError display ")" 155 | syn match cErrInParen display contained "<%\|%>" 156 | else 157 | syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell 158 | " cCppParen: same as cParen but ends at end-of-line; used in cDefine 159 | syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell 160 | syn match cParenError display ")" 161 | syn match cErrInParen display contained "[{}]\|<%\|%>" 162 | endif 163 | else 164 | if s:in_cpp_family && !exists("cpp_no_cpp11") 165 | syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell 166 | " cCppParen: same as cParen but ends at end-of-line; used in cDefine 167 | syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell 168 | syn match cParenError display "[\])]" 169 | syn match cErrInParen display contained "<%\|%>" 170 | syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@cStringGroup,@Spell 171 | else 172 | syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell 173 | " cCppParen: same as cParen but ends at end-of-line; used in cDefine 174 | syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell 175 | syn match cParenError display "[\])]" 176 | syn match cErrInParen display contained "[\]{}]\|<%\|%>" 177 | syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@cStringGroup,@Spell 178 | endif 179 | " cCppBracket: same as cParen but ends at end-of-line; used in cDefine 180 | syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell 181 | syn match cErrInBracket display contained "[);{}]\|<%\|%>" 182 | endif 183 | 184 | if s:ft ==# 'c' || exists("cpp_no_cpp11") 185 | syn region cBadBlock keepend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold 186 | endif 187 | 188 | "integer number, or floating point number without a dot and with "f". 189 | syn case ignore 190 | syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal 191 | " Same, but without octal error (for comments) 192 | syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctal 193 | syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" 194 | "hex number 195 | syn match cNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" 196 | " Flag the first zero of an octal number as something special 197 | syn match cOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero 198 | syn match cOctalZero display contained "\<0" 199 | syn match cFloat display contained "\d\+f" 200 | "floating point number, with dot, optional exponent 201 | syn match cFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=" 202 | "floating point number, starting with a dot, optional exponent 203 | syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" 204 | "floating point number, without dot, with exponent 205 | syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" 206 | if !exists("c_no_c99") 207 | "hexadecimal floating point number, optional leading digits, with dot, with exponent 208 | syn match cFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>" 209 | "hexadecimal floating point number, with leading digits, optional dot, with exponent 210 | syn match cFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>" 211 | endif 212 | 213 | " flag an octal number with wrong digits 214 | syn match cOctalError display contained "0\o*[89]\d*" 215 | syn case match 216 | 217 | if exists("c_comment_strings") 218 | " A comment can contain cString, cCharacter and cNumber. 219 | " But a "*/" inside a cString in a cComment DOES end the comment! So we 220 | " need to use a special type of cString: cCommentString, which also ends on 221 | " "*/", and sees a "*" at the start of the line as comment again. 222 | " Unfortunately this doesn't very well work for // type of comments :-( 223 | syn match cCommentSkip contained "^\s*\*\($\|\s\+\)" 224 | syn region cCommentString contained start=+L\=\\\@" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError 380 | syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>" 381 | if !exists("c_no_if0") 382 | syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip 383 | syn region cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold 384 | syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse 385 | if !exists("c_no_if0_fold") 386 | syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold 387 | else 388 | syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell 389 | endif 390 | syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit 391 | syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold 392 | syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit 393 | if !exists("c_no_if0_fold") 394 | syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold 395 | else 396 | syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 397 | endif 398 | syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell 399 | syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip 400 | syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc 401 | endif 402 | syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ 403 | syn match cIncluded display contained "<[^>]*>" 404 | syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded 405 | "syn match cLineSkip "\\$" 406 | syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti,cBadBlock 407 | syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell 408 | syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell 409 | 410 | " Optional embedded Autodoc parsing 411 | if exists("c_autodoc") 412 | syn match cAutodocReal display contained "\%(//\|[/ \t\v]\*\|^\*\)\@2<=!.*" contains=@cAutodoc containedin=cComment,cCommentL 413 | syn cluster cCommentGroup add=cAutodocReal 414 | syn cluster cPreProcGroup add=cAutodocReal 415 | endif 416 | 417 | " be able to fold #pragma regions 418 | syn region cPragma start="^\s*#pragma\s\+region\>" end="^\s*#pragma\s\+endregion\>" transparent keepend extend fold 419 | 420 | " Highlight User Labels 421 | syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString 422 | if s:ft ==# 'c' || exists("cpp_no_cpp11") 423 | syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell,@cStringGroup 424 | endif 425 | " Avoid matching foo::bar() in C++ by requiring that the next char is not ':' 426 | syn cluster cLabelGroup contains=cUserLabel 427 | syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup 428 | syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup 429 | if s:in_cpp_family 430 | syn match cUserCont display "^\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup 431 | syn match cUserCont display ";\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup 432 | else 433 | syn match cUserCont display "^\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup 434 | syn match cUserCont display ";\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup 435 | endif 436 | 437 | syn match cUserLabel display "\I\i*" contained 438 | 439 | " Avoid recognizing most bitfields as labels 440 | syn match cBitField display "^\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType 441 | syn match cBitField display ";\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType 442 | 443 | if exists("c_minlines") 444 | let b:c_minlines = c_minlines 445 | else 446 | if !exists("c_no_if0") 447 | let b:c_minlines = 50 " #if 0 constructs can be long 448 | else 449 | let b:c_minlines = 15 " mostly for () constructs 450 | endif 451 | endif 452 | if exists("c_curly_error") 453 | syn sync fromstart 454 | else 455 | exec "syn sync ccomment cComment minlines=" . b:c_minlines 456 | endif 457 | 458 | " Define the default highlighting. 459 | " Only used when an item doesn't have highlighting yet 460 | hi def link cFormat cSpecial 461 | hi def link cCppString cString 462 | hi def link cCommentL cComment 463 | hi def link cCommentStart cComment 464 | hi def link cLabel Label 465 | hi def link cUserLabel Label 466 | hi def link cConditional Conditional 467 | hi def link cRepeat Repeat 468 | hi def link cCharacter Character 469 | hi def link cSpecialCharacter cSpecial 470 | hi def link cNumber Number 471 | hi def link cOctal Number 472 | hi def link cOctalZero PreProc " link this to Error if you want 473 | hi def link cFloat Float 474 | hi def link cOctalError cError 475 | hi def link cParenError cError 476 | hi def link cErrInParen cError 477 | hi def link cErrInBracket cError 478 | hi def link cCommentError cError 479 | hi def link cCommentStartError cError 480 | hi def link cSpaceError cError 481 | hi def link cWrongComTail cError 482 | hi def link cSpecialError cError 483 | hi def link cCurlyError cError 484 | hi def link cOperator Operator 485 | hi def link cStructure Structure 486 | hi def link cTypedef Structure 487 | hi def link cStorageClass StorageClass 488 | hi def link cInclude Include 489 | hi def link cPreProc PreProc 490 | hi def link cDefine Macro 491 | hi def link cIncluded cString 492 | hi def link cError Error 493 | hi def link cStatement Statement 494 | hi def link cCppInWrapper cCppOutWrapper 495 | hi def link cCppOutWrapper cPreCondit 496 | hi def link cPreConditMatch cPreCondit 497 | hi def link cPreCondit PreCondit 498 | hi def link cType Type 499 | hi def link cConstant Constant 500 | hi def link cCommentString cString 501 | hi def link cComment2String cString 502 | hi def link cCommentSkip cComment 503 | hi def link cString String 504 | hi def link cComment Comment 505 | hi def link cSpecial SpecialChar 506 | hi def link cTodo Todo 507 | hi def link cBadContinuation Error 508 | hi def link cCppOutSkip cCppOutIf2 509 | hi def link cCppInElse2 cCppOutIf2 510 | hi def link cCppOutIf2 cCppOut 511 | hi def link cCppOut Comment 512 | 513 | let b:current_syntax = "c" 514 | 515 | unlet s:ft 516 | 517 | let &cpo = s:cpo_save 518 | unlet s:cpo_save 519 | " vim: ts=8 520 | --------------------------------------------------------------------------------