c.vim (33920B)
1 " Vim syntax file 2 " Language: C 3 " Maintainer: The Vim Project <https://github.com/vim/vim> 4 " Last Change: 2026 Jan 13 5 " Former Maintainer: Bram Moolenaar <Bram@vim.org> 6 7 " Quit when a (custom) syntax file was already loaded 8 if exists("b:current_syntax") 9 finish 10 endif 11 12 let s:cpo_save = &cpo 13 set cpo&vim 14 15 let s:ft = matchstr(&ft, '^\%([^.]\)\+') 16 17 " check if this was included from cpp.vim 18 let s:in_cpp_family = exists("b:filetype_in_cpp_family") 19 20 " Optional embedded Autodoc parsing 21 " To enable it add: let g:c_autodoc = 1 22 " to your .vimrc 23 if exists("c_autodoc") 24 syn include @cAutodoc <sfile>:p:h/autodoc.vim 25 unlet b:current_syntax 26 endif 27 28 " A bunch of useful C keywords 29 syn keyword cStatement goto break return continue asm 30 syn keyword cLabel case default 31 syn keyword cConditional if else switch 32 syn keyword cRepeat while for do 33 34 syn keyword cTodo contained TODO FIXME XXX 35 36 " It's easy to accidentally add a space after a backslash that was intended 37 " for line continuation. Some compilers allow it, which makes it 38 " unpredictable and should be avoided. 39 syn match cBadContinuation contained "\\\s\+$" 40 41 " cCommentGroup allows adding matches for special things in comments 42 syn cluster cCommentGroup contains=cTodo,cBadContinuation 43 44 " String and Character constants 45 " Highlight special characters (those which have a backslash) differently 46 syn match cSpecial display contained "\\\%(x\x\+\|\o\{1,3}\|.\|$\)" 47 if !exists("c_no_utf") 48 syn match cSpecial display contained "\\\%(u\x\{4}\|U\x\{8}\)" 49 endif 50 51 if !exists("c_no_cformat") 52 " Highlight % items in strings. 53 if !exists("c_no_c99") " ISO C99 54 syn match cFormat display "%\%(\d\+\$\)\=[-+' #0*]*\%(\d*\|\*\|\*\d\+\$\)\%(\.\%(\d*\|\*\|\*\d\+\$\)\)\=\%([hlLjzt]\|ll\|hh\)\=\%([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained 55 else 56 syn match cFormat display "%\%(\d\+\$\)\=[-+' #0*]*\%(\d*\|\*\|\*\d\+\$\)\%(\.\%(\d*\|\*\|\*\d\+\$\)\)\=\%([hlL]\|ll\)\=\%([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained 57 endif 58 syn match cFormat display "%%" contained 59 endif 60 61 " cCppString: same as cString, but ends at end of line 62 if s:in_cpp_family && !exists("cpp_no_cpp11") && !exists("c_no_cformat") 63 " ISO C++11 64 syn region cString start=+\%(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend 65 syn region cCppString start=+\%(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell 66 elseif s:ft ==# "c" && !exists("c_no_c11") && !exists("c_no_cformat") 67 " ISO C99 68 syn region cString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend 69 syn region cCppString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell 70 else 71 " older C or C++ 72 syn match cFormat display "%%" contained 73 syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend 74 syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell 75 endif 76 77 syn region cCppSkip contained start="^\s*\%(%:\|#\)\s*\%(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\%(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip 78 79 syn cluster cStringGroup contains=cCppString,cCppSkip 80 81 syn match cCharacter "L\='[^\\]'" 82 syn match cCharacter "L'[^']*'" contains=cSpecial 83 if exists("c_gnu") 84 syn match cSpecialError "L\='\\[^'\"?\\abefnrtv]'" 85 syn match cSpecialCharacter "L\='\\['\"?\\abefnrtv]'" 86 else 87 syn match cSpecialError "L\='\\[^'\"?\\abfnrtv]'" 88 syn match cSpecialCharacter "L\='\\['\"?\\abfnrtv]'" 89 endif 90 syn match cSpecialCharacter display "L\='\\\o\{1,3}'" 91 syn match cSpecialCharacter display "'\\x\x\{1,2}'" 92 syn match cSpecialCharacter display "L'\\x\x\+'" 93 94 if (s:ft ==# "c" && !exists("c_no_c11")) || (s:in_cpp_family && !exists("cpp_no_cpp11")) 95 " ISO C11 or ISO C++ 11 96 if exists("c_no_cformat") 97 syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend 98 else 99 syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend 100 endif 101 syn match cCharacter "[Uu]'[^\\]'" 102 syn match cCharacter "[Uu]'[^']*'" contains=cSpecial 103 if exists("c_gnu") 104 syn match cSpecialError "[Uu]'\\[^'\"?\\abefnrtv]'" 105 syn match cSpecialCharacter "[Uu]'\\['\"?\\abefnrtv]'" 106 else 107 syn match cSpecialError "[Uu]'\\[^'\"?\\abfnrtv]'" 108 syn match cSpecialCharacter "[Uu]'\\['\"?\\abfnrtv]'" 109 endif 110 syn match cSpecialCharacter display "[Uu]'\\\o\{1,3}'" 111 syn match cSpecialCharacter display "[Uu]'\\x\x\+'" 112 endif 113 114 if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp17")) 115 syn match cCharacter "u8'[^\\]'" 116 syn match cCharacter "u8'[^']*'" contains=cSpecial 117 if exists("c_gnu") 118 syn match cSpecialError "u8'\\[^'\"?\\abefnrtv]'" 119 syn match cSpecialCharacter "u8'\\['\"?\\abefnrtv]'" 120 else 121 syn match cSpecialError "u8'\\[^'\"?\\abfnrtv]'" 122 syn match cSpecialCharacter "u8'\\['\"?\\abfnrtv]'" 123 endif 124 syn match cSpecialCharacter display "u8'\\\o\{1,3}'" 125 syn match cSpecialCharacter display "u8'\\x\x\+'" 126 endif 127 128 "when wanted, highlight trailing white space 129 if exists("c_space_errors") 130 if !exists("c_no_trail_space_error") 131 syn match cSpaceError display excludenl "\s\+$" 132 endif 133 if !exists("c_no_tab_space_error") 134 syn match cSpaceError display " \+\t"me=e-1 135 endif 136 endif 137 138 " This should be before cErrInParen to avoid problems with #define ({ xxx }) 139 if exists("c_curly_error") 140 syn match cCurlyError "}" 141 syn region cBlock start="{" end="}" contains=ALLBUT,cBadBlock,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell fold 142 else 143 syn region cBlock start="{" end="}" transparent fold 144 endif 145 146 " Catch errors caused by wrong parenthesis and brackets. 147 " Also accept <% for {, %> for }, <: for [ and :> for ] (C99) 148 " But avoid matching <::. 149 syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom 150 if exists("c_no_curly_error") 151 if s:in_cpp_family && !exists("cpp_no_cpp11") 152 syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell 153 " cCppParen: same as cParen but ends at end-of-line; used in cDefine 154 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell 155 syn match cParenError display ")" 156 syn match cErrInParen display contained "^^<%\|^%>" 157 else 158 syn region cParen transparent start='(' end=')' contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell 159 " cCppParen: same as cParen but ends at end-of-line; used in cDefine 160 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell 161 syn match cParenError display ")" 162 syn match cErrInParen display contained "^[{}]\|^<%\|^%>" 163 endif 164 elseif exists("c_no_bracket_error") 165 if s:in_cpp_family && !exists("cpp_no_cpp11") 166 syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell 167 " cCppParen: same as cParen but ends at end-of-line; used in cDefine 168 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell 169 syn match cParenError display ")" 170 syn match cErrInParen display contained "<%\|%>" 171 else 172 syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@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,cParen,cString,@Spell 175 syn match cParenError display ")" 176 syn match cErrInParen display contained "[{}]\|<%\|%>" 177 endif 178 else 179 if s:in_cpp_family && !exists("cpp_no_cpp11") 180 syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell 181 " cCppParen: same as cParen but ends at end-of-line; used in cDefine 182 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell 183 syn match cParenError display "[\])]" 184 syn match cErrInParen display contained "<%\|%>" 185 syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@cStringGroup,@Spell 186 else 187 syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell 188 " cCppParen: same as cParen but ends at end-of-line; used in cDefine 189 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell 190 syn match cParenError display "[\])]" 191 syn match cErrInParen display contained "[\]{}]\|<%\|%>" 192 syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@cStringGroup,@Spell 193 endif 194 " cCppBracket: same as cParen but ends at end-of-line; used in cDefine 195 syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell 196 syn match cErrInBracket display contained "[);{}]\|<%\|%>" 197 endif 198 199 if s:ft ==# 'c' || exists("cpp_no_cpp11") 200 syn region cBadBlock keepend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold 201 endif 202 203 "integer number, or floating point number without a dot and with "f". 204 syn case ignore 205 syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal 206 " Same, but without octal error (for comments) 207 syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctal 208 209 " cpp.vim handles these 210 if !exists("c_no_c23") && !s:in_cpp_family 211 syn match cNumber display contained "\d\%('\=\d\+\)*\%(u\=l\{0,2}\|ll\=u\|u\=wb\|wbu\=\)\>" 212 "hex number 213 syn match cNumber display contained "0x\x\%('\=\x\+\)*\%(u\=l\{0,2}\|ll\=u\|u\=wb\|wbu\=\)\>" 214 " Flag the first zero of an octal number as something special 215 syn match cOctal display contained "0\o\%('\=\o\+\)*\%(u\=l\{0,2}\|ll\=u\|u\=wb\|wbu\=\)\>" contains=cOctalZero 216 "binary number 217 syn match cNumber display contained "0b[01]\%('\=[01]\+\)*\%(u\=l\{0,2}\|ll\=u\|u\=wb\|wbu\=\)\>" 218 else 219 syn match cNumber display contained "\d\+\%(u\=l\{0,2}\|ll\=u\)\>" 220 "hex number 221 syn match cNumber display contained "0x\x\+\%(u\=l\{0,2}\|ll\=u\)\>" 222 " Flag the first zero of an octal number as something special 223 syn match cOctal display contained "0\o\+\%(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero 224 syn match cOctalZero display contained "\<0" 225 endif 226 227 "floating point number, with dot, optional exponent 228 syn match cFloat display contained "\d\+\.\d*\%(e[-+]\=\d\+\)\=[fl]\=" 229 "floating point number, starting with a dot, optional exponent 230 syn match cFloat display contained "\.\d\+\%(e[-+]\=\d\+\)\=[fl]\=\>" 231 "floating point number, without dot, with exponent 232 syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" 233 if !exists("c_no_c99") 234 "hexadecimal floating point number, optional leading digits, with dot, with exponent 235 syn match cFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>" 236 "hexadecimal floating point number, with leading digits, optional dot, with exponent 237 syn match cFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>" 238 endif 239 240 " flag an octal number with wrong digits 241 syn match cOctalError display contained "0\o*[89]\d*" 242 syn case match 243 244 if exists("c_comment_strings") 245 " A comment can contain cString, cCharacter and cNumber. 246 " But a "*/" inside a cString in a cComment DOES end the comment! So we 247 " need to use a special type of cString: cCommentString, which also ends on 248 " "*/", and sees a "*" at the start of the line as comment again. 249 " Unfortunately this doesn't very well work for // type of comments :-( 250 syn match cCommentSkip contained "^\s*\*\%($\|\s\+\)" 251 syn region cCommentString contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=cSpecial,cCommentSkip 252 syn region cComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=cSpecial 253 syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError,cWrongComTail,@Spell 254 if exists("c_no_comment_fold") 255 " Use "extend" here to have preprocessor lines not terminate halfway a 256 " comment. 257 syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell extend 258 else 259 syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell fold extend 260 endif 261 else 262 syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cSpaceError,@Spell 263 if exists("c_no_comment_fold") 264 syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell extend 265 else 266 syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell fold extend 267 endif 268 endif 269 " keep a // comment separately, it terminates a preproc. conditional 270 syn match cCommentError display "\*/" 271 syn match cCommentStartError display "/\*"me=e-1 contained 272 syn match cWrongComTail display "\*/" 273 274 syn keyword cOperator sizeof 275 if exists("c_gnu") 276 syn keyword cType __label__ __complex__ 277 syn keyword cStatement __asm__ 278 syn keyword cOperator __alignof__ 279 syn keyword cOperator typeof __typeof__ 280 syn keyword cOperator __real__ __imag__ 281 syn keyword cStorageClass __attribute__ __const__ __extension__ 282 syn keyword cStorageClass inline __inline __inline__ 283 syn keyword cStorageClass __restrict__ __volatile__ __noreturn__ 284 endif 285 syn keyword cType int long short char void 286 syn keyword cType signed unsigned float double 287 if !exists("c_no_ansi") || exists("c_ansi_typedefs") 288 syn keyword cType size_t ssize_t off_t wchar_t ptrdiff_t sig_atomic_t fpos_t 289 syn keyword cType clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t 290 syn keyword cType mbstate_t wctrans_t wint_t wctype_t 291 endif 292 if !exists("c_no_c99") " ISO C99 293 syn keyword cType _Bool bool _Complex complex _Imaginary imaginary 294 syn keyword cType int8_t int16_t int32_t int64_t 295 syn keyword cType uint8_t uint16_t uint32_t uint64_t 296 if !exists("c_no_bsd") 297 " These are BSD specific. 298 syn keyword cType u_int8_t u_int16_t u_int32_t u_int64_t 299 endif 300 syn keyword cType int_least8_t int_least16_t int_least32_t int_least64_t 301 syn keyword cType uint_least8_t uint_least16_t uint_least32_t uint_least64_t 302 syn keyword cType int_fast8_t int_fast16_t int_fast32_t int_fast64_t 303 syn keyword cType uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t 304 syn keyword cType intptr_t uintptr_t 305 syn keyword cType intmax_t uintmax_t 306 endif 307 if !exists("c_no_c23") && !s:in_cpp_family 308 syn keyword cOperator typeof typeof_unqual 309 syn keyword cType _BitInt _Decimal32 _Decimal64 _Decimal128 310 endif 311 if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp11")) 312 syn keyword cType nullptr_t 313 endif 314 315 syn keyword cTypedef typedef 316 syn keyword cStructure struct union enum 317 syn keyword cStorageClass static register auto volatile extern const 318 if !exists("c_no_c99") && !s:in_cpp_family 319 syn keyword cStorageClass inline restrict 320 endif 321 if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp11")) 322 syn keyword cStorageClass constexpr 323 endif 324 if !exists("c_no_c11") 325 syn keyword cStorageClass _Alignas alignas 326 syn keyword cOperator _Alignof alignof 327 syn keyword cStorageClass _Atomic 328 syn keyword cOperator _Generic 329 syn keyword cStorageClass _Noreturn 330 if !s:in_cpp_family 331 syn keyword cStorageClass noreturn 332 endif 333 syn keyword cOperator _Static_assert static_assert 334 syn keyword cStorageClass _Thread_local thread_local 335 syn keyword cType char16_t char32_t 336 syn keyword cType max_align_t 337 " C11 atomics (take down the shield wall!) 338 syn keyword cType atomic_bool atomic_char atomic_schar atomic_uchar 339 syn keyword Ctype atomic_short atomic_ushort atomic_int atomic_uint 340 syn keyword cType atomic_long atomic_ulong atomic_llong atomic_ullong 341 syn keyword cType atomic_char16_t atomic_char32_t atomic_wchar_t 342 syn keyword cType atomic_int_least8_t atomic_uint_least8_t 343 syn keyword cType atomic_int_least16_t atomic_uint_least16_t 344 syn keyword cType atomic_int_least32_t atomic_uint_least32_t 345 syn keyword cType atomic_int_least64_t atomic_uint_least64_t 346 syn keyword cType atomic_int_fast8_t atomic_uint_fast8_t 347 syn keyword cType atomic_int_fast16_t atomic_uint_fast16_t 348 syn keyword cType atomic_int_fast32_t atomic_uint_fast32_t 349 syn keyword cType atomic_int_fast64_t atomic_uint_fast64_t 350 syn keyword cType atomic_intptr_t atomic_uintptr_t 351 syn keyword cType atomic_size_t atomic_ptrdiff_t 352 syn keyword cType atomic_intmax_t atomic_uintmax_t 353 endif 354 355 if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp20")) 356 syn keyword cType char8_t 357 endif 358 359 if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu") 360 if exists("c_gnu") 361 syn keyword cConstant __GNUC__ __FUNCTION__ __PRETTY_FUNCTION__ __func__ 362 endif 363 " TODO: __STDC_HOSTED__ is C99 and C++11 364 syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __STDC_HOSTED__ 365 syn keyword cConstant CHAR_BIT MB_LEN_MAX MB_CUR_MAX 366 syn keyword cConstant UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX 367 syn keyword cConstant CHAR_MIN INT_MIN LONG_MIN SHRT_MIN 368 syn keyword cConstant CHAR_MAX INT_MAX LONG_MAX SHRT_MAX 369 syn keyword cConstant SCHAR_MIN SINT_MIN SLONG_MIN SSHRT_MIN 370 syn keyword cConstant SCHAR_MAX SINT_MAX SLONG_MAX SSHRT_MAX 371 if !exists("c_no_c99") 372 syn keyword cConstant __STDC_ISO_10646__ __STDC_IEC_559_COMPLEX__ 373 syn keyword cConstant __STDC_MB_MIGHT_NEQ_WC__ 374 syn keyword cConstant __func__ __VA_ARGS__ 375 syn keyword cConstant LLONG_MIN LLONG_MAX ULLONG_MAX 376 syn keyword cConstant INT8_MIN INT16_MIN INT32_MIN INT64_MIN 377 syn keyword cConstant INT8_MAX INT16_MAX INT32_MAX INT64_MAX 378 syn keyword cConstant UINT8_MAX UINT16_MAX UINT32_MAX UINT64_MAX 379 syn keyword cConstant INT_LEAST8_MIN INT_LEAST16_MIN INT_LEAST32_MIN INT_LEAST64_MIN 380 syn keyword cConstant INT_LEAST8_MAX INT_LEAST16_MAX INT_LEAST32_MAX INT_LEAST64_MAX 381 syn keyword cConstant UINT_LEAST8_MAX UINT_LEAST16_MAX UINT_LEAST32_MAX UINT_LEAST64_MAX 382 syn keyword cConstant INT_FAST8_MIN INT_FAST16_MIN INT_FAST32_MIN INT_FAST64_MIN 383 syn keyword cConstant INT_FAST8_MAX INT_FAST16_MAX INT_FAST32_MAX INT_FAST64_MAX 384 syn keyword cConstant UINT_FAST8_MAX UINT_FAST16_MAX UINT_FAST32_MAX UINT_FAST64_MAX 385 syn keyword cConstant INTPTR_MIN INTPTR_MAX UINTPTR_MAX 386 syn keyword cConstant INTMAX_MIN INTMAX_MAX UINTMAX_MAX 387 syn keyword cConstant PTRDIFF_MIN PTRDIFF_MAX SIG_ATOMIC_MIN SIG_ATOMIC_MAX 388 syn keyword cConstant SIZE_MAX WCHAR_MIN WCHAR_MAX WINT_MIN WINT_MAX 389 endif 390 if !exists("c_no_c11") 391 syn keyword cConstant __STDC_UTF_16__ __STDC_UTF_32__ __STDC_ANALYZABLE__ 392 syn keyword cConstant __STDC_LIB_EXT1__ __STDC_NO_ATOMICS__ 393 syn keyword cConstant __STDC_NO_COMPLEX__ __STDC_NO_THREADS__ 394 syn keyword cConstant __STDC_NO_VLA__ 395 endif 396 if !exists("c_no_c23") 397 syn keyword cConstant __STDC_UTF_16__ __STDC_UTF_32__ 398 syn keyword cConstant __STDC_EMBED_NOT_FOUND__ __STDC_EMBED_FOUND__ 399 syn keyword cConstant __STDC_EMBED_EMPTY__ __STDC_IEC_60559_BFP__ 400 syn keyword cConstant __STDC_IEC_60559_DFP__ __STDC_IEC_60559_COMPLEX__ 401 syn keyword cConstant __STDC_IEC_60559_TYPES__ 402 syn keyword cConstant BITINT_MAXWIDTH 403 endif 404 if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp20")) 405 syn keyword cConstant __VA_OPT__ 406 endif 407 if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp11")) 408 syn keyword cConstant nullptr 409 endif 410 syn keyword cConstant FLT_RADIX FLT_ROUNDS FLT_DIG FLT_MANT_DIG FLT_EPSILON DBL_DIG DBL_MANT_DIG DBL_EPSILON 411 syn keyword cConstant LDBL_DIG LDBL_MANT_DIG LDBL_EPSILON FLT_MIN FLT_MAX FLT_MIN_EXP FLT_MAX_EXP FLT_MIN_10_EXP FLT_MAX_10_EXP 412 syn keyword cConstant DBL_MIN DBL_MAX DBL_MIN_EXP DBL_MAX_EXP DBL_MIN_10_EXP DBL_MAX_10_EXP LDBL_MIN LDBL_MAX LDBL_MIN_EXP LDBL_MAX_EXP 413 syn keyword cConstant LDBL_MIN_10_EXP LDBL_MAX_10_EXP HUGE_VAL CLOCKS_PER_SEC NULL LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY 414 syn keyword cConstant LC_NUMERIC LC_TIME SIG_DFL SIG_ERR SIG_IGN SIGABRT SIGFPE SIGILL SIGHUP SIGINT SIGSEGV SIGTERM 415 " Add POSIX signals as well... 416 syn keyword cConstant SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV 417 syn keyword cConstant SIGSTOP SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 418 syn keyword cConstant _IOFBF _IOLBF _IONBF BUFSIZ EOF WEOF FOPEN_MAX FILENAME_MAX L_tmpnam 419 syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET TMP_MAX EXIT_FAILURE EXIT_SUCCESS RAND_MAX 420 syn keyword cConstant stdin stdout stderr 421 " POSIX 2001, in unistd.h 422 syn keyword cConstant STDIN_FILENO STDOUT_FILENO STDERR_FILENO 423 " used in assert.h 424 syn keyword cConstant NDEBUG 425 " POSIX 2001 426 syn keyword cConstant SIGBUS SIGPOLL SIGPROF SIGSYS SIGURG SIGVTALRM SIGXCPU SIGXFSZ 427 " POSIX Issue 8 (post 2017) 428 syn keyword cConstant SIGWINCH 429 " non-POSIX signals 430 syn keyword cConstant SIGINFO SIGIO 431 " Add POSIX errors as well. List comes from: 432 " http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html 433 syn keyword cConstant E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT EAGAIN EALREADY EBADF 434 syn keyword cConstant EBADMSG EBUSY ECANCELED ECHILD ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK 435 syn keyword cConstant EDESTADDRREQ EDOM EDQUOT EEXIST EFAULT EFBIG EHOSTUNREACH EIDRM EILSEQ 436 syn keyword cConstant EINPROGRESS EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK EMSGSIZE 437 syn keyword cConstant EMULTIHOP ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH ENFILE ENOBUFS ENODATA 438 syn keyword cConstant ENODEV ENOENT ENOEXEC ENOLCK ENOLINK ENOMEM ENOMSG ENOPROTOOPT ENOSPC ENOSR 439 syn keyword cConstant ENOSTR ENOSYS ENOTBLK ENOTCONN ENOTDIR ENOTEMPTY ENOTRECOVERABLE ENOTSOCK ENOTSUP 440 syn keyword cConstant ENOTTY ENXIO EOPNOTSUPP EOVERFLOW EOWNERDEAD EPERM EPIPE EPROTO 441 syn keyword cConstant EPROTONOSUPPORT EPROTOTYPE ERANGE EROFS ESPIPE ESRCH ESTALE ETIME ETIMEDOUT 442 syn keyword cConstant ETXTBSY EWOULDBLOCK EXDEV 443 " math.h 444 syn keyword cConstant M_E M_LOG2E M_LOG10E M_LN2 M_LN10 M_PI M_PI_2 M_PI_4 445 syn keyword cConstant M_1_PI M_2_PI M_2_SQRTPI M_SQRT2 M_SQRT1_2 446 endif 447 if !exists("c_no_c99") " ISO C99 448 syn keyword cConstant true false 449 syn keyword cConstant INFINITY NAN 450 " math.h 451 syn keyword cConstant HUGE_VAL HUGE_VALF HUGE_VALL 452 syn keyword cConstant FP_FAST_FMAF FP_FAST_FMA FP_FAST_FMAL 453 syn keyword cConstant FP_ILOGB0 FP_ILOGBNAN 454 syn keyword cConstant math_errhandling MATH_ERRNO MATH_ERREXCEPT 455 syn keyword cConstant FP_NORMAL FP_SUBNORMAL FP_ZERO FP_INFINITE FP_NAN 456 endif 457 458 " Accept %: for # (C99) 459 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 460 if !exists("c_no_c23") 461 syn region cPreCondit start="^\s*\zs\%(%:\|#\)\s*\%(el\)\=\%(if\|ifdef\|ifndef\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError 462 else 463 syn region cPreCondit start="^\s*\zs\%(%:\|#\)\s*\%(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError 464 endif 465 syn match cPreConditMatch display "^\s*\zs\%(%:\|#\)\s*\%(else\|endif\)\>" 466 if !exists("c_no_if0") 467 syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip 468 syn region cCppOutWrapper start="^\s*\zs\%(%:\|#\)\s*if\s\+0\+\s*\%($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold 469 syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\%(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse 470 if !exists("c_no_if0_fold") 471 if !exists("c_no_c23") 472 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\%(%:\|#\)\s*\%(else\>\|el\%(if\|ifdef\|ifndef\)\s\+\%(0\+\s*\%($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold 473 else 474 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 475 endif 476 else 477 if !exists("c_no_c23") 478 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\%(%:\|#\)\s*\%(else\>\|el\%(if\|ifdef\|ifndef\)\s\+\%(0\+\s*\%($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell 479 else 480 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\%(%:\|#\)\s*\%(else\>\|elif\s\+\%(0\+\s*\%($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell 481 endif 482 endif 483 if !exists("c_no_c23") 484 syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\%(%:\|#\)\s*\%(else\|el\%(if\|ifdef\|ifndef\)\)" end="^\s*\%(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit 485 else 486 syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\%(%:\|#\)\s*\%(else\|elif\)" end="^\s*\%(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit 487 endif 488 syn region cCppInWrapper start="^\s*\zs\%(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\%($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold 489 syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\%(%:\|#\)\s*endif\>" contains=TOP,cPreCondit 490 if !exists("c_no_if0_fold") 491 if !exists("c_no_c23") 492 syn region cCppInElse contained start="^\s*\%(%:\|#\)\s*\%(else\>\|el\%(if\|ifdef\|ifndef\)\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold 493 else 494 syn region cCppInElse contained start="^\s*\%(%:\|#\)\s*\%(else\>\|elif\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold 495 endif 496 else 497 if !exists("c_no_c23") 498 syn region cCppInElse contained start="^\s*\%(%:\|#\)\s*\%(else\>\|el\%(if\|ifdef\|ifndef\)\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 499 else 500 syn region cCppInElse contained start="^\s*\%(%:\|#\)\s*\%(else\>\|elif\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 501 endif 502 endif 503 if !exists("c_no_c23") 504 syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\%(%:\|#\)\s*\%(else\|el\%(if\|ifdef\|ifndef\)\)\%([^/]\|/[^/*]\)*" end="^\s*\%(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell 505 else 506 syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\%(%:\|#\)\s*\%(else\|elif\)\%([^/]\|/[^/*]\)*" end="^\s*\%(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell 507 endif 508 syn region cCppOutSkip contained start="^\s*\%(%:\|#\)\s*\%(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\%(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip 509 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 510 endif 511 syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ 512 syn match cIncluded display contained "<[^>]*>" 513 syn match cInclude display "^\s*\zs\%(%:\|#\)\s*include\>\s*["<]" contains=cIncluded 514 if !exists("c_no_c23") && !s:in_cpp_family 515 syn region cInclude start="^\s*\zs\%(%:\|#\)\s*embed\>" skip="\\$" end="$" keepend contains=cEmbed,cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError 516 syn match cEmbed contained "\%(%:\|#\)\s*embed\>" nextgroup=cIncluded skipwhite transparent 517 syn cluster cPreProcGroup add=cEmbed 518 endif 519 "syn match cLineSkip "\\$" 520 syn region cDefine start="^\s*\zs\%(%:\|#\)\s*\%(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell 521 syn region cPreProc start="^\s*\zs\%(%:\|#\)\s*\%(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell 522 523 " Optional embedded Autodoc parsing 524 if exists("c_autodoc") 525 syn match cAutodocReal display contained "\%(//\|[/ \t\v]\*\|^\*\)\@2<=!.*" contains=@cAutodoc containedin=cComment,cCommentL 526 syn cluster cCommentGroup add=cAutodocReal 527 syn cluster cPreProcGroup add=cAutodocReal 528 endif 529 530 " be able to fold #pragma regions 531 syn region cPragma start="^\s*#pragma\s\+region\>" end="^\s*#pragma\s\+endregion\>" transparent keepend extend fold 532 533 " Highlight User Labels 534 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 535 if s:ft ==# 'c' || exists("cpp_no_cpp11") 536 syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell,@cStringGroup 537 endif 538 " Avoid matching foo::bar() in C++ by requiring that the next char is not ':' 539 syn cluster cLabelGroup contains=cUserLabel 540 syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup 541 syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup 542 if s:in_cpp_family 543 syn match cUserCont display "^\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup 544 syn match cUserCont display ";\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup 545 else 546 syn match cUserCont display "^\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup 547 syn match cUserCont display ";\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup 548 endif 549 550 syn match cUserLabel display "\I\i*" contained 551 552 " Avoid recognizing most bitfields as labels 553 syn match cBitField display "^\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType 554 syn match cBitField display ";\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType 555 556 if exists("c_functions") 557 syn match cFunction "\<\h\w*\ze\_s*(" 558 endif 559 560 if exists("c_function_pointers") 561 syn match cFunctionPointer "\%((\s*\*\s*\)\@<=\h\w*\ze\s*)\_s*(.*)" 562 endif 563 564 if exists("c_minlines") 565 let b:c_minlines = c_minlines 566 else 567 if !exists("c_no_if0") 568 let b:c_minlines = 50 " #if 0 constructs can be long 569 else 570 let b:c_minlines = 15 " mostly for () constructs 571 endif 572 endif 573 if exists("c_curly_error") 574 syn sync fromstart 575 else 576 exec "syn sync ccomment cComment minlines=" . b:c_minlines 577 endif 578 579 " Define the default highlighting. 580 " Only used when an item doesn't have highlighting yet 581 hi def link cFormat cSpecial 582 hi def link cCppString cString 583 hi def link cCommentL cComment 584 hi def link cCommentStart cComment 585 hi def link cLabel Label 586 hi def link cUserLabel Label 587 hi def link cConditional Conditional 588 hi def link cRepeat Repeat 589 hi def link cCharacter Character 590 hi def link cSpecialCharacter cSpecial 591 hi def link cNumber Number 592 hi def link cOctal Number 593 hi def link cOctalZero PreProc " link this to Error if you want 594 hi def link cFloat Float 595 hi def link cOctalError cError 596 hi def link cParenError cError 597 hi def link cErrInParen cError 598 hi def link cErrInBracket cError 599 hi def link cCommentError cError 600 hi def link cCommentStartError cError 601 hi def link cSpaceError cError 602 hi def link cWrongComTail cError 603 hi def link cSpecialError cError 604 hi def link cCurlyError cError 605 hi def link cOperator Operator 606 hi def link cStructure Structure 607 hi def link cTypedef Structure 608 hi def link cStorageClass StorageClass 609 hi def link cInclude Include 610 hi def link cPreProc PreProc 611 hi def link cDefine Macro 612 hi def link cIncluded cString 613 hi def link cError Error 614 hi def link cStatement Statement 615 hi def link cCppInWrapper cCppOutWrapper 616 hi def link cCppOutWrapper cPreCondit 617 hi def link cPreConditMatch cPreCondit 618 hi def link cPreCondit PreCondit 619 hi def link cType Type 620 hi def link cConstant Constant 621 hi def link cCommentString cString 622 hi def link cComment2String cString 623 hi def link cCommentSkip cComment 624 hi def link cString String 625 hi def link cComment Comment 626 hi def link cSpecial SpecialChar 627 hi def link cTodo Todo 628 hi def link cBadContinuation Error 629 hi def link cCppOutSkip cCppOutIf2 630 hi def link cCppInElse2 cCppOutIf2 631 hi def link cCppOutIf2 cCppOut 632 hi def link cCppOut Comment 633 hi def link cFunction Function 634 hi def link cFunctionPointer Function 635 636 let b:current_syntax = "c" 637 638 unlet s:ft 639 640 let &cpo = s:cpo_save 641 unlet s:cpo_save 642 " vim: ts=8