codekingpro/portable-devtools
114k
1" Vim syntax file2" Language: C3" Maintainer: The Vim Project <https://github.com/vim/vim>4" Last Change: 2026 Jan 135" Former Maintainer: Bram Moolenaar <Bram@vim.org>6 7" Quit when a (custom) syntax file was already loaded8if exists("b:current_syntax")9 finish10endif11 12let s:cpo_save = &cpo13set cpo&vim14 15let s:ft = matchstr(&ft, '^\%([^.]\)\+')16 17" check if this was included from cpp.vim18let s:in_cpp_family = exists("b:filetype_in_cpp_family")19 20" Optional embedded Autodoc parsing21" To enable it add: let g:c_autodoc = 122" to your .vimrc23if exists("c_autodoc")24 syn include @cAutodoc <sfile>:p:h/autodoc.vim25 unlet b:current_syntax26endif27 28" A bunch of useful C keywords29syn keyword cStatement goto break return continue asm30syn keyword cLabel case default31syn keyword cConditional if else switch32syn keyword cRepeat while for do33 34syn keyword cTodo contained TODO FIXME XXX35 36" It's easy to accidentally add a space after a backslash that was intended37" for line continuation. Some compilers allow it, which makes it38" unpredictable and should be avoided.39syn match cBadContinuation contained "\\\s\+$"40 41" cCommentGroup allows adding matches for special things in comments42syn cluster cCommentGroup contains=cTodo,cBadContinuation43 44" String and Character constants45" Highlight special characters (those which have a backslash) differently46syn match cSpecial display contained "\\\%(x\x\+\|\o\{1,3}\|.\|$\)"47if !exists("c_no_utf")48 syn match cSpecial display contained "\\\%(u\x\{4}\|U\x\{8}\)"49endif50 51if !exists("c_no_cformat")52 " Highlight % items in strings.53 if !exists("c_no_c99") " ISO C9954 syn match cFormat display "%\%(\d\+\$\)\=[-+' #0*]*\%(\d*\|\*\|\*\d\+\$\)\%(\.\%(\d*\|\*\|\*\d\+\$\)\)\=\%([hlLjzt]\|ll\|hh\)\=\%([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained55 else56 syn match cFormat display "%\%(\d\+\$\)\=[-+' #0*]*\%(\d*\|\*\|\*\d\+\$\)\%(\.\%(\d*\|\*\|\*\d\+\$\)\)\=\%([hlL]\|ll\)\=\%([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained57 endif58 syn match cFormat display "%%" contained59endif60 61" cCppString: same as cString, but ends at end of line62if s:in_cpp_family && !exists("cpp_no_cpp11") && !exists("c_no_cformat")63 " ISO C++1164 syn region cString start=+\%(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend65 syn region cCppString start=+\%(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell66elseif s:ft ==# "c" && !exists("c_no_c11") && !exists("c_no_cformat")67 " ISO C9968 syn region cString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend69 syn region cCppString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell70else71 " older C or C++72 syn match cFormat display "%%" contained73 syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend74 syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell75endif76 77syn region cCppSkip contained start="^\s*\%(%:\|#\)\s*\%(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\%(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip78 79syn cluster cStringGroup contains=cCppString,cCppSkip80 81syn match cCharacter "L\='[^\\]'"82syn match cCharacter "L'[^']*'" contains=cSpecial83if exists("c_gnu")84 syn match cSpecialError "L\='\\[^'\"?\\abefnrtv]'"85 syn match cSpecialCharacter "L\='\\['\"?\\abefnrtv]'"86else87 syn match cSpecialError "L\='\\[^'\"?\\abfnrtv]'"88 syn match cSpecialCharacter "L\='\\['\"?\\abfnrtv]'"89endif90syn match cSpecialCharacter display "L\='\\\o\{1,3}'"91syn match cSpecialCharacter display "'\\x\x\{1,2}'"92syn match cSpecialCharacter display "L'\\x\x\+'"93 94if (s:ft ==# "c" && !exists("c_no_c11")) || (s:in_cpp_family && !exists("cpp_no_cpp11"))95 " ISO C11 or ISO C++ 1196 if exists("c_no_cformat")97 syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend98 else99 syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend100 endif101 syn match cCharacter "[Uu]'[^\\]'"102 syn match cCharacter "[Uu]'[^']*'" contains=cSpecial103 if exists("c_gnu")104 syn match cSpecialError "[Uu]'\\[^'\"?\\abefnrtv]'"105 syn match cSpecialCharacter "[Uu]'\\['\"?\\abefnrtv]'"106 else107 syn match cSpecialError "[Uu]'\\[^'\"?\\abfnrtv]'"108 syn match cSpecialCharacter "[Uu]'\\['\"?\\abfnrtv]'"109 endif110 syn match cSpecialCharacter display "[Uu]'\\\o\{1,3}'"111 syn match cSpecialCharacter display "[Uu]'\\x\x\+'"112endif113 114if (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=cSpecial117 if exists("c_gnu")118 syn match cSpecialError "u8'\\[^'\"?\\abefnrtv]'"119 syn match cSpecialCharacter "u8'\\['\"?\\abefnrtv]'"120 else121 syn match cSpecialError "u8'\\[^'\"?\\abfnrtv]'"122 syn match cSpecialCharacter "u8'\\['\"?\\abfnrtv]'"123 endif124 syn match cSpecialCharacter display "u8'\\\o\{1,3}'"125 syn match cSpecialCharacter display "u8'\\x\x\+'"126endif127 128"when wanted, highlight trailing white space129if exists("c_space_errors")130 if !exists("c_no_trail_space_error")131 syn match cSpaceError display excludenl "\s\+$"132 endif133 if !exists("c_no_tab_space_error")134 syn match cSpaceError display " \+\t"me=e-1135 endif136endif137 138" This should be before cErrInParen to avoid problems with #define ({ xxx })139if 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 fold142else143 syn region cBlock start="{" end="}" transparent fold144endif145 146" Catch errors caused by wrong parenthesis and brackets.147" Also accept <% for {, %> for }, <: for [ and :> for ] (C99)148" But avoid matching <::.149syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom150if 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,@Spell153 " cCppParen: same as cParen but ends at end-of-line; used in cDefine154 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell155 syn match cParenError display ")"156 syn match cErrInParen display contained "^^<%\|^%>"157 else158 syn region cParen transparent start='(' end=')' contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell159 " cCppParen: same as cParen but ends at end-of-line; used in cDefine160 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell161 syn match cParenError display ")"162 syn match cErrInParen display contained "^[{}]\|^<%\|^%>"163 endif164elseif 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,@Spell167 " cCppParen: same as cParen but ends at end-of-line; used in cDefine168 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell169 syn match cParenError display ")"170 syn match cErrInParen display contained "<%\|%>"171 else172 syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell173 " cCppParen: same as cParen but ends at end-of-line; used in cDefine174 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell175 syn match cParenError display ")"176 syn match cErrInParen display contained "[{}]\|<%\|%>"177 endif178else179 if s:in_cpp_family && !exists("cpp_no_cpp11")180 syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell181 " cCppParen: same as cParen but ends at end-of-line; used in cDefine182 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell183 syn match cParenError display "[\])]"184 syn match cErrInParen display contained "<%\|%>"185 syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@cStringGroup,@Spell186 else187 syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell188 " cCppParen: same as cParen but ends at end-of-line; used in cDefine189 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell190 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,@Spell193 endif194 " cCppBracket: same as cParen but ends at end-of-line; used in cDefine195 syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell196 syn match cErrInBracket display contained "[);{}]\|<%\|%>"197endif198 199if s:ft ==# 'c' || exists("cpp_no_cpp11")200 syn region cBadBlock keepend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold201endif202 203"integer number, or floating point number without a dot and with "f".204syn case ignore205syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal206" Same, but without octal error (for comments)207syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctal208 209" cpp.vim handles these210if !exists("c_no_c23") && !s:in_cpp_family211 syn match cNumber display contained "\d\%('\=\d\+\)*\%(u\=l\{0,2}\|ll\=u\|u\=wb\|wbu\=\)\>"212 "hex number213 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 special215 syn match cOctal display contained "0\o\%('\=\o\+\)*\%(u\=l\{0,2}\|ll\=u\|u\=wb\|wbu\=\)\>" contains=cOctalZero216 "binary number217 syn match cNumber display contained "0b[01]\%('\=[01]\+\)*\%(u\=l\{0,2}\|ll\=u\|u\=wb\|wbu\=\)\>"218else219 syn match cNumber display contained "\d\+\%(u\=l\{0,2}\|ll\=u\)\>"220 "hex number221 syn match cNumber display contained "0x\x\+\%(u\=l\{0,2}\|ll\=u\)\>"222 " Flag the first zero of an octal number as something special223 syn match cOctal display contained "0\o\+\%(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero224 syn match cOctalZero display contained "\<0"225endif226 227"floating point number, with dot, optional exponent228syn match cFloat display contained "\d\+\.\d*\%(e[-+]\=\d\+\)\=[fl]\="229"floating point number, starting with a dot, optional exponent230syn match cFloat display contained "\.\d\+\%(e[-+]\=\d\+\)\=[fl]\=\>"231"floating point number, without dot, with exponent232syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"233if !exists("c_no_c99")234 "hexadecimal floating point number, optional leading digits, with dot, with exponent235 syn match cFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>"236 "hexadecimal floating point number, with leading digits, optional dot, with exponent237 syn match cFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>"238endif239 240" flag an octal number with wrong digits241syn match cOctalError display contained "0\o*[89]\d*"242syn case match243 244if 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 we247 " need to use a special type of cString: cCommentString, which also ends on248 " "*/", 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,cCommentSkip252 syn region cComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=cSpecial253 syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError,cWrongComTail,@Spell254 if exists("c_no_comment_fold")255 " Use "extend" here to have preprocessor lines not terminate halfway a256 " comment.257 syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell extend258 else259 syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell fold extend260 endif261else262 syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cSpaceError,@Spell263 if exists("c_no_comment_fold")264 syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell extend265 else266 syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell fold extend267 endif268endif269" keep a // comment separately, it terminates a preproc. conditional270syn match cCommentError display "\*/"271syn match cCommentStartError display "/\*"me=e-1 contained272syn match cWrongComTail display "\*/"273 274syn keyword cOperator sizeof275if 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__284endif285syn keyword cType int long short char void286syn keyword cType signed unsigned float double287if !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_t289 syn keyword cType clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t290 syn keyword cType mbstate_t wctrans_t wint_t wctype_t291endif292if !exists("c_no_c99") " ISO C99293 syn keyword cType _Bool bool _Complex complex _Imaginary imaginary294 syn keyword cType int8_t int16_t int32_t int64_t295 syn keyword cType uint8_t uint16_t uint32_t uint64_t296 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_t299 endif300 syn keyword cType int_least8_t int_least16_t int_least32_t int_least64_t301 syn keyword cType uint_least8_t uint_least16_t uint_least32_t uint_least64_t302 syn keyword cType int_fast8_t int_fast16_t int_fast32_t int_fast64_t303 syn keyword cType uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t304 syn keyword cType intptr_t uintptr_t305 syn keyword cType intmax_t uintmax_t306endif307if !exists("c_no_c23") && !s:in_cpp_family308 syn keyword cOperator typeof typeof_unqual309 syn keyword cType _BitInt _Decimal32 _Decimal64 _Decimal128310endif311if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp11"))312 syn keyword cType nullptr_t313endif314 315syn keyword cTypedef typedef316syn keyword cStructure struct union enum317syn keyword cStorageClass static register auto volatile extern const318if !exists("c_no_c99") && !s:in_cpp_family319 syn keyword cStorageClass inline restrict320endif321if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp11"))322 syn keyword cStorageClass constexpr323endif324if !exists("c_no_c11")325 syn keyword cStorageClass _Alignas alignas326 syn keyword cOperator _Alignof alignof327 syn keyword cStorageClass _Atomic328 syn keyword cOperator _Generic329 syn keyword cStorageClass _Noreturn330 if !s:in_cpp_family331 syn keyword cStorageClass noreturn332 endif333 syn keyword cOperator _Static_assert static_assert334 syn keyword cStorageClass _Thread_local thread_local335 syn keyword cType char16_t char32_t336 syn keyword cType max_align_t337 " C11 atomics (take down the shield wall!)338 syn keyword cType atomic_bool atomic_char atomic_schar atomic_uchar339 syn keyword Ctype atomic_short atomic_ushort atomic_int atomic_uint340 syn keyword cType atomic_long atomic_ulong atomic_llong atomic_ullong341 syn keyword cType atomic_char16_t atomic_char32_t atomic_wchar_t342 syn keyword cType atomic_int_least8_t atomic_uint_least8_t343 syn keyword cType atomic_int_least16_t atomic_uint_least16_t344 syn keyword cType atomic_int_least32_t atomic_uint_least32_t345 syn keyword cType atomic_int_least64_t atomic_uint_least64_t346 syn keyword cType atomic_int_fast8_t atomic_uint_fast8_t347 syn keyword cType atomic_int_fast16_t atomic_uint_fast16_t348 syn keyword cType atomic_int_fast32_t atomic_uint_fast32_t349 syn keyword cType atomic_int_fast64_t atomic_uint_fast64_t350 syn keyword cType atomic_intptr_t atomic_uintptr_t351 syn keyword cType atomic_size_t atomic_ptrdiff_t352 syn keyword cType atomic_intmax_t atomic_uintmax_t353endif354 355if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp20"))356 syn keyword cType char8_t357endif358 359if !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 endif363 " TODO: __STDC_HOSTED__ is C99 and C++11364 syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __STDC_HOSTED__365 syn keyword cConstant CHAR_BIT MB_LEN_MAX MB_CUR_MAX366 syn keyword cConstant UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX367 syn keyword cConstant CHAR_MIN INT_MIN LONG_MIN SHRT_MIN368 syn keyword cConstant CHAR_MAX INT_MAX LONG_MAX SHRT_MAX369 syn keyword cConstant SCHAR_MIN SINT_MIN SLONG_MIN SSHRT_MIN370 syn keyword cConstant SCHAR_MAX SINT_MAX SLONG_MAX SSHRT_MAX371 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_MAX376 syn keyword cConstant INT8_MIN INT16_MIN INT32_MIN INT64_MIN377 syn keyword cConstant INT8_MAX INT16_MAX INT32_MAX INT64_MAX378 syn keyword cConstant UINT8_MAX UINT16_MAX UINT32_MAX UINT64_MAX379 syn keyword cConstant INT_LEAST8_MIN INT_LEAST16_MIN INT_LEAST32_MIN INT_LEAST64_MIN380 syn keyword cConstant INT_LEAST8_MAX INT_LEAST16_MAX INT_LEAST32_MAX INT_LEAST64_MAX381 syn keyword cConstant UINT_LEAST8_MAX UINT_LEAST16_MAX UINT_LEAST32_MAX UINT_LEAST64_MAX382 syn keyword cConstant INT_FAST8_MIN INT_FAST16_MIN INT_FAST32_MIN INT_FAST64_MIN383 syn keyword cConstant INT_FAST8_MAX INT_FAST16_MAX INT_FAST32_MAX INT_FAST64_MAX384 syn keyword cConstant UINT_FAST8_MAX UINT_FAST16_MAX UINT_FAST32_MAX UINT_FAST64_MAX385 syn keyword cConstant INTPTR_MIN INTPTR_MAX UINTPTR_MAX386 syn keyword cConstant INTMAX_MIN INTMAX_MAX UINTMAX_MAX387 syn keyword cConstant PTRDIFF_MIN PTRDIFF_MAX SIG_ATOMIC_MIN SIG_ATOMIC_MAX388 syn keyword cConstant SIZE_MAX WCHAR_MIN WCHAR_MAX WINT_MIN WINT_MAX389 endif390 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 endif396 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_MAXWIDTH403 endif404 if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp20"))405 syn keyword cConstant __VA_OPT__406 endif407 if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp11"))408 syn keyword cConstant nullptr409 endif410 syn keyword cConstant FLT_RADIX FLT_ROUNDS FLT_DIG FLT_MANT_DIG FLT_EPSILON DBL_DIG DBL_MANT_DIG DBL_EPSILON411 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_EXP412 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_EXP413 syn keyword cConstant LDBL_MIN_10_EXP LDBL_MAX_10_EXP HUGE_VAL CLOCKS_PER_SEC NULL LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY414 syn keyword cConstant LC_NUMERIC LC_TIME SIG_DFL SIG_ERR SIG_IGN SIGABRT SIGFPE SIGILL SIGHUP SIGINT SIGSEGV SIGTERM415 " Add POSIX signals as well...416 syn keyword cConstant SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV417 syn keyword cConstant SIGSTOP SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2418 syn keyword cConstant _IOFBF _IOLBF _IONBF BUFSIZ EOF WEOF FOPEN_MAX FILENAME_MAX L_tmpnam419 syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET TMP_MAX EXIT_FAILURE EXIT_SUCCESS RAND_MAX420 syn keyword cConstant stdin stdout stderr421 " POSIX 2001, in unistd.h422 syn keyword cConstant STDIN_FILENO STDOUT_FILENO STDERR_FILENO423 " used in assert.h424 syn keyword cConstant NDEBUG425 " POSIX 2001426 syn keyword cConstant SIGBUS SIGPOLL SIGPROF SIGSYS SIGURG SIGVTALRM SIGXCPU SIGXFSZ427 " POSIX Issue 8 (post 2017)428 syn keyword cConstant SIGWINCH429 " non-POSIX signals430 syn keyword cConstant SIGINFO SIGIO431 " Add POSIX errors as well. List comes from:432 " http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html433 syn keyword cConstant E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT EAGAIN EALREADY EBADF434 syn keyword cConstant EBADMSG EBUSY ECANCELED ECHILD ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK435 syn keyword cConstant EDESTADDRREQ EDOM EDQUOT EEXIST EFAULT EFBIG EHOSTUNREACH EIDRM EILSEQ436 syn keyword cConstant EINPROGRESS EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK EMSGSIZE437 syn keyword cConstant EMULTIHOP ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH ENFILE ENOBUFS ENODATA438 syn keyword cConstant ENODEV ENOENT ENOEXEC ENOLCK ENOLINK ENOMEM ENOMSG ENOPROTOOPT ENOSPC ENOSR439 syn keyword cConstant ENOSTR ENOSYS ENOTBLK ENOTCONN ENOTDIR ENOTEMPTY ENOTRECOVERABLE ENOTSOCK ENOTSUP440 syn keyword cConstant ENOTTY ENXIO EOPNOTSUPP EOVERFLOW EOWNERDEAD EPERM EPIPE EPROTO441 syn keyword cConstant EPROTONOSUPPORT EPROTOTYPE ERANGE EROFS ESPIPE ESRCH ESTALE ETIME ETIMEDOUT442 syn keyword cConstant ETXTBSY EWOULDBLOCK EXDEV443 " math.h444 syn keyword cConstant M_E M_LOG2E M_LOG10E M_LN2 M_LN10 M_PI M_PI_2 M_PI_4445 syn keyword cConstant M_1_PI M_2_PI M_2_SQRTPI M_SQRT2 M_SQRT1_2446endif447if !exists("c_no_c99") " ISO C99448 syn keyword cConstant true false449 syn keyword cConstant INFINITY NAN450 " math.h451 syn keyword cConstant HUGE_VAL HUGE_VALF HUGE_VALL452 syn keyword cConstant FP_FAST_FMAF FP_FAST_FMA FP_FAST_FMAL453 syn keyword cConstant FP_ILOGB0 FP_ILOGBNAN454 syn keyword cConstant math_errhandling MATH_ERRNO MATH_ERREXCEPT455 syn keyword cConstant FP_NORMAL FP_SUBNORMAL FP_ZERO FP_INFINITE FP_NAN456endif457 458" Accept %: for # (C99)459syn 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,cBadBlock460if !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,cSpaceError462else463 syn region cPreCondit start="^\s*\zs\%(%:\|#\)\s*\%(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError464endif465syn match cPreConditMatch display "^\s*\zs\%(%:\|#\)\s*\%(else\|endif\)\>"466if !exists("c_no_if0")467 syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip468 syn region cCppOutWrapper start="^\s*\zs\%(%:\|#\)\s*if\s\+0\+\s*\%($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold469 syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\%(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse470 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 fold473 else474 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\%(%:\|#\)\s*\%(else\>\|elif\s\+\%(0\+\s*\%($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold475 endif476 else477 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,@Spell479 else480 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\%(%:\|#\)\s*\%(else\>\|elif\s\+\%(0\+\s*\%($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell481 endif482 endif483 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,cPreCondit485 else486 syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\%(%:\|#\)\s*\%(else\|elif\)" end="^\s*\%(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit487 endif488 syn region cCppInWrapper start="^\s*\zs\%(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\%($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold489 syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\%(%:\|#\)\s*endif\>" contains=TOP,cPreCondit490 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 fold493 else494 syn region cCppInElse contained start="^\s*\%(%:\|#\)\s*\%(else\>\|elif\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold495 endif496 else497 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=cCppInElse2499 else500 syn region cCppInElse contained start="^\s*\%(%:\|#\)\s*\%(else\>\|elif\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2501 endif502 endif503 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,@Spell505 else506 syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\%(%:\|#\)\s*\%(else\|elif\)\%([^/]\|/[^/*]\)*" end="^\s*\%(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell507 endif508 syn region cCppOutSkip contained start="^\s*\%(%:\|#\)\s*\%(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\%(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip509 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,cPreProc510endif511syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+512syn match cIncluded display contained "<[^>]*>"513syn match cInclude display "^\s*\zs\%(%:\|#\)\s*include\>\s*["<]" contains=cIncluded514if !exists("c_no_c23") && !s:in_cpp_family515 syn region cInclude start="^\s*\zs\%(%:\|#\)\s*embed\>" skip="\\$" end="$" keepend contains=cEmbed,cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError516 syn match cEmbed contained "\%(%:\|#\)\s*embed\>" nextgroup=cIncluded skipwhite transparent517 syn cluster cPreProcGroup add=cEmbed518endif519"syn match cLineSkip "\\$"520syn region cDefine start="^\s*\zs\%(%:\|#\)\s*\%(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell521syn region cPreProc start="^\s*\zs\%(%:\|#\)\s*\%(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell522 523" Optional embedded Autodoc parsing524if exists("c_autodoc")525 syn match cAutodocReal display contained "\%(//\|[/ \t\v]\*\|^\*\)\@2<=!.*" contains=@cAutodoc containedin=cComment,cCommentL526 syn cluster cCommentGroup add=cAutodocReal527 syn cluster cPreProcGroup add=cAutodocReal528endif529 530" be able to fold #pragma regions531syn region cPragma start="^\s*#pragma\s\+region\>" end="^\s*#pragma\s\+endregion\>" transparent keepend extend fold532 533" Highlight User Labels534syn 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,cCppString535if s:ft ==# 'c' || exists("cpp_no_cpp11")536 syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell,@cStringGroup537endif538" Avoid matching foo::bar() in C++ by requiring that the next char is not ':'539syn cluster cLabelGroup contains=cUserLabel540syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup541syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup542if s:in_cpp_family543 syn match cUserCont display "^\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup544 syn match cUserCont display ";\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup545else546 syn match cUserCont display "^\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup547 syn match cUserCont display ";\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup548endif549 550syn match cUserLabel display "\I\i*" contained551 552" Avoid recognizing most bitfields as labels553syn match cBitField display "^\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType554syn match cBitField display ";\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType555 556if exists("c_functions")557 syn match cFunction "\<\h\w*\ze\_s*("558 endif559 560if exists("c_function_pointers")561 syn match cFunctionPointer "\%((\s*\*\s*\)\@<=\h\w*\ze\s*)\_s*(.*)"562endif563 564if exists("c_minlines")565 let b:c_minlines = c_minlines566else567 if !exists("c_no_if0")568 let b:c_minlines = 50 " #if 0 constructs can be long569 else570 let b:c_minlines = 15 " mostly for () constructs571 endif572endif573if exists("c_curly_error")574 syn sync fromstart575else576 exec "syn sync ccomment cComment minlines=" . b:c_minlines577endif578 579" Define the default highlighting.580" Only used when an item doesn't have highlighting yet581hi def link cFormat cSpecial582hi def link cCppString cString583hi def link cCommentL cComment584hi def link cCommentStart cComment585hi def link cLabel Label586hi def link cUserLabel Label587hi def link cConditional Conditional588hi def link cRepeat Repeat589hi def link cCharacter Character590hi def link cSpecialCharacter cSpecial591hi def link cNumber Number592hi def link cOctal Number593hi def link cOctalZero PreProc " link this to Error if you want594hi def link cFloat Float595hi def link cOctalError cError596hi def link cParenError cError597hi def link cErrInParen cError598hi def link cErrInBracket cError599hi def link cCommentError cError600hi def link cCommentStartError cError601hi def link cSpaceError cError602hi def link cWrongComTail cError603hi def link cSpecialError cError604hi def link cCurlyError cError605hi def link cOperator Operator606hi def link cStructure Structure607hi def link cTypedef Structure608hi def link cStorageClass StorageClass609hi def link cInclude Include610hi def link cPreProc PreProc611hi def link cDefine Macro612hi def link cIncluded cString613hi def link cError Error614hi def link cStatement Statement615hi def link cCppInWrapper cCppOutWrapper616hi def link cCppOutWrapper cPreCondit617hi def link cPreConditMatch cPreCondit618hi def link cPreCondit PreCondit619hi def link cType Type620hi def link cConstant Constant621hi def link cCommentString cString622hi def link cComment2String cString623hi def link cCommentSkip cComment624hi def link cString String625hi def link cComment Comment626hi def link cSpecial SpecialChar627hi def link cTodo Todo628hi def link cBadContinuation Error629hi def link cCppOutSkip cCppOutIf2630hi def link cCppInElse2 cCppOutIf2631hi def link cCppOutIf2 cCppOut632hi def link cCppOut Comment633hi def link cFunction Function634hi def link cFunctionPointer Function635 636let b:current_syntax = "c"637 638unlet s:ft639 640let &cpo = s:cpo_save641unlet s:cpo_save642" vim: ts=8643 