1
1
" Vim syntax file
2
2
" Language: C
3
3
" Maintainer: Bram Moolenaar <[email protected] >
4
- " Last Change: 2016 Nov 18
4
+ " Last Change: 2019 Nov 29
5
5
6
6
" Quit when a (custom) syntax file was already loaded
7
7
if exists (" b:current_syntax" )
@@ -13,6 +13,14 @@ set cpo&vim
13
13
14
14
let s: ft = matchstr (&ft , ' ^\([^.]\)\+' )
15
15
16
+ " Optional embedded Autodoc parsing
17
+ " To enable it add: let g:c_autodoc = 1
18
+ " to your .vimrc
19
+ if exists (" c_autodoc" )
20
+ syn include @cAutodoc <sfile> :p:h/autodoc.vim
21
+ unlet b: current_syntax
22
+ endif
23
+
16
24
" A bunch of useful C keywords
17
25
syn keyword cStatement goto break return continue asm
18
26
syn keyword cLabel case default
@@ -129,7 +137,7 @@ if exists("c_no_curly_error")
129
137
syn match cParenError display " )"
130
138
syn match cErrInParen display contained " ^^<%\| ^%>"
131
139
else
132
- syn region cParen transparent start =' (' end =' )' end = ' } ' me = s - 1 contains =ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell
140
+ syn region cParen transparent start =' (' end =' )' contains =ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell
133
141
" cCppParen: same as cParen but ends at end-of-line; used in cDefine
134
142
syn region cCppParen transparent start =' (' skip =' \\ $' excludenl end =' )' end =' $' contained contains =ALLBUT,@cParenGroup,cParen,cString,@Spell
135
143
syn match cParenError display " )"
@@ -212,7 +220,7 @@ if exists("c_comment_strings")
212
220
syn match cCommentSkip contained " ^\s *\*\( $\|\s\+\) "
213
221
syn region cCommentString contained start =+ L\=\\\@ <!"+ skip =+ \\\\\|\\ "+ end =+ "+ end =+ \* /+ me =s - 1 contains =cSpecial,cCommentSkip
214
222
syn region cComment2String contained start =+ L\=\\\@ <!"+ skip =+ \\\\\|\\ "+ end =+ "+ end =" $" contains =cSpecial
215
- syn region cCommentL start =" //" skip =" \\ $" end =" $" keepend contains =@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError,@Spell
223
+ syn region cCommentL start =" //" skip =" \\ $" end =" $" keepend contains =@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError,cWrongComTail, @Spell
216
224
if exists (" c_no_comment_fold" )
217
225
" Use "extend" here to have preprocessor lines not terminate halfway a
218
226
" comment.
@@ -231,6 +239,7 @@ endif
231
239
" keep a // comment separately, it terminates a preproc. conditional
232
240
syn match cCommentError display " \* /"
233
241
syn match cCommentStartError display " /\* " me =e - 1 contained
242
+ syn match cWrongComTail display " \* /"
234
243
235
244
syn keyword cOperator sizeof
236
245
if exists (" c_gnu" )
@@ -280,6 +289,22 @@ if !exists("c_no_c11")
280
289
syn keyword cOperator _Static_assert static_assert
281
290
syn keyword cStorageClass _Thread_local thread_local
282
291
syn keyword cType char16_t char32_t
292
+ " C11 atomics (take down the shield wall!)
293
+ syn keyword cType atomic_bool atomic_char atomic_schar atomic_uchar
294
+ syn keyword Ctype atomic_short atomic_ushort atomic_int atomic_uint
295
+ syn keyword cType atomic_long atomic_ulong atomic_llong atomic_ullong
296
+ syn keyword cType atomic_char16_t atomic_char32_t atomic_wchar_t
297
+ syn keyword cType atomic_int_least8_t atomic_uint_least8_t
298
+ syn keyword cType atomic_int_least16_t atomic_uint_least16_t
299
+ syn keyword cType atomic_int_least32_t atomic_uint_least32_t
300
+ syn keyword cType atomic_int_least64_t atomic_uint_least64_t
301
+ syn keyword cType atomic_int_fast8_t atomic_uint_fast8_t
302
+ syn keyword cType atomic_int_fast16_t atomic_uint_fast16_t
303
+ syn keyword cType atomic_int_fast32_t atomic_uint_fast32_t
304
+ syn keyword cType atomic_int_fast64_t atomic_uint_fast64_t
305
+ syn keyword cType atomic_intptr_t atomic_uintptr_t
306
+ syn keyword cType atomic_size_t atomic_ptrdiff_t
307
+ syn keyword cType atomic_intmax_t atomic_uintmax_t
283
308
endif
284
309
285
310
if ! exists (" c_no_ansi" ) || exists (" c_ansi_constants" ) || exists (" c_gnu" )
@@ -311,44 +336,32 @@ if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu")
311
336
syn keyword cConstant PTRDIFF_MIN PTRDIFF_MAX SIG_ATOMIC_MIN SIG_ATOMIC_MAX
312
337
syn keyword cConstant SIZE_MAX WCHAR_MIN WCHAR_MAX WINT_MIN WINT_MAX
313
338
endif
314
- syn keyword cConstant FLT_RADIX FLT_ROUNDS
315
- syn keyword cConstant FLT_DIG FLT_MANT_DIG FLT_EPSILON
316
- syn keyword cConstant DBL_DIG DBL_MANT_DIG DBL_EPSILON
317
- syn keyword cConstant LDBL_DIG LDBL_MANT_DIG LDBL_EPSILON
318
- syn keyword cConstant FLT_MIN FLT_MAX FLT_MIN_EXP FLT_MAX_EXP
319
- syn keyword cConstant FLT_MIN_10_EXP FLT_MAX_10_EXP
320
- syn keyword cConstant DBL_MIN DBL_MAX DBL_MIN_EXP DBL_MAX_EXP
321
- syn keyword cConstant DBL_MIN_10_EXP DBL_MAX_10_EXP
322
- syn keyword cConstant LDBL_MIN LDBL_MAX LDBL_MIN_EXP LDBL_MAX_EXP
323
- syn keyword cConstant LDBL_MIN_10_EXP LDBL_MAX_10_EXP
324
- syn keyword cConstant HUGE_VAL CLOCKS_PER_SEC NULL
325
- syn keyword cConstant LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY
326
- syn keyword cConstant LC_NUMERIC LC_TIME
327
- syn keyword cConstant SIG_DFL SIG_ERR SIG_IGN
328
- syn keyword cConstant SIGABRT SIGFPE SIGILL SIGHUP SIGINT SIGSEGV SIGTERM
339
+ syn keyword cConstant FLT_RADIX FLT_ROUNDS FLT_DIG FLT_MANT_DIG FLT_EPSILON DBL_DIG DBL_MANT_DIG DBL_EPSILON
340
+ 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
341
+ 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
342
+ 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
343
+ syn keyword cConstant LC_NUMERIC LC_TIME SIG_DFL SIG_ERR SIG_IGN SIGABRT SIGFPE SIGILL SIGHUP SIGINT SIGSEGV SIGTERM
329
344
" Add POSIX signals as well...
330
- syn keyword cConstant SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP
331
- syn keyword cConstant SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV
332
- syn keyword cConstant SIGSTOP SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU
333
- syn keyword cConstant SIGUSR1 SIGUSR2
334
- syn keyword cConstant _IOFBF _IOLBF _IONBF BUFSIZ EOF WEOF
335
- syn keyword cConstant FOPEN_MAX FILENAME_MAX L_tmpnam
336
- syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET
337
- syn keyword cConstant TMP_MAX stderr stdin stdout
338
- syn keyword cConstant EXIT_FAILURE EXIT_SUCCESS RAND_MAX
345
+ syn keyword cConstant SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV
346
+ syn keyword cConstant SIGSTOP SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2
347
+ syn keyword cConstant _IOFBF _IOLBF _IONBF BUFSIZ EOF WEOF FOPEN_MAX FILENAME_MAX L_tmpnam
348
+ syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET TMP_MAX stderr stdin stdout EXIT_FAILURE EXIT_SUCCESS RAND_MAX
339
349
" POSIX 2001
340
- syn keyword cConstant SIGBUS SIGPOLL SIGPROF SIGSYS SIGURG
341
- syn keyword cConstant SIGVTALRM SIGXCPU SIGXFSZ
350
+ syn keyword cConstant SIGBUS SIGPOLL SIGPROF SIGSYS SIGURG SIGVTALRM SIGXCPU SIGXFSZ
342
351
" non-POSIX signals
343
352
syn keyword cConstant SIGWINCH SIGINFO
344
- " Add POSIX errors as well
345
- syn keyword cConstant E2BIG EACCES EAGAIN EBADF EBADMSG EBUSY
346
- syn keyword cConstant ECANCELED ECHILD EDEADLK EDOM EEXIST EFAULT
347
- syn keyword cConstant EFBIG EILSEQ EINPROGRESS EINTR EINVAL EIO EISDIR
348
- syn keyword cConstant EMFILE EMLINK EMSGSIZE ENAMETOOLONG ENFILE ENODEV
349
- syn keyword cConstant ENOENT ENOEXEC ENOLCK ENOMEM ENOSPC ENOSYS
350
- syn keyword cConstant ENOTDIR ENOTEMPTY ENOTSUP ENOTTY ENXIO EPERM
351
- syn keyword cConstant EPIPE ERANGE EROFS ESPIPE ESRCH ETIMEDOUT EXDEV
353
+ " Add POSIX errors as well. List comes from:
354
+ " http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
355
+ syn keyword cConstant E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT EAGAIN EALREADY EBADF
356
+ syn keyword cConstant EBADMSG EBUSY ECANCELED ECHILD ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK
357
+ syn keyword cConstant EDESTADDRREQ EDOM EDQUOT EEXIST EFAULT EFBIG EHOSTUNREACH EIDRM EILSEQ
358
+ syn keyword cConstant EINPROGRESS EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK EMSGSIZE
359
+ syn keyword cConstant EMULTIHOP ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH ENFILE ENOBUFS ENODATA
360
+ syn keyword cConstant ENODEV ENOENT ENOEXEC ENOLCK ENOLINK ENOMEM ENOMSG ENOPROTOOPT ENOSPC ENOSR
361
+ syn keyword cConstant ENOSTR ENOSYS ENOTBLK ENOTCONN ENOTDIR ENOTEMPTY ENOTRECOVERABLE ENOTSOCK ENOTSUP
362
+ syn keyword cConstant ENOTTY ENXIO EOPNOTSUPP EOVERFLOW EOWNERDEAD EPERM EPIPE EPROTO
363
+ syn keyword cConstant EPROTONOSUPPORT EPROTOTYPE ERANGE EROFS ESPIPE ESRCH ESTALE ETIME ETIMEDOUT
364
+ syn keyword cConstant ETXTBSY EWOULDBLOCK EXDEV
352
365
" math.h
353
366
syn keyword cConstant M_E M_LOG2E M_LOG10E M_LN2 M_LN10 M_PI M_PI_2 M_PI_4
354
367
syn keyword cConstant M_1_PI M_2_PI M_2_SQRTPI M_SQRT2 M_SQRT1_2
@@ -389,6 +402,13 @@ syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInP
389
402
syn region cDefine start =" ^\s *\z s\( %:\| #\)\s *\( define\| undef\)\> " skip =" \\ $" end =" $" keepend contains =ALLBUT,@cPreProcGroup,@Spell
390
403
syn region cPreProc start =" ^\s *\z s\( %:\| #\)\s *\( pragma\>\| line\>\| warning\>\| warn\>\| error\>\) " skip =" \\ $" end =" $" keepend contains =ALLBUT,@cPreProcGroup,@Spell
391
404
405
+ " Optional embedded Autodoc parsing
406
+ if exists (" c_autodoc" )
407
+ syn match cAutodocReal display contained " \% (//\| [/ \t\v ]\*\| ^\*\)\@ 2<=!.*" contains =@cAutodoc containedin =cComment,cCommentL
408
+ syn cluster cCommentGroup add =cAutodocReal
409
+ syn cluster cPreProcGroup add =cAutodocReal
410
+ endif
411
+
392
412
" Highlight User Labels
393
413
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
394
414
if s: ft == # ' c' || exists (" cpp_no_cpp11" )
@@ -450,6 +470,7 @@ hi def link cErrInBracket cError
450
470
hi def link cCommentError cError
451
471
hi def link cCommentStartError cError
452
472
hi def link cSpaceError cError
473
+ hi def link cWrongComTail cError
453
474
hi def link cSpecialError cError
454
475
hi def link cCurlyError cError
455
476
hi def link cOperator Operator
0 commit comments