1
1
" Vim syntax file
2
2
" Language: C
3
3
" Maintainer: Bram Moolenaar <Bram@vim.org>
4
- " Last Change: 2014 Nov 13
4
+ " Last Change: 2015 Mar 05
5
5
6
6
" Quit when a (custom) syntax file was already loaded
7
7
if exists (" b:current_syntax" )
@@ -47,16 +47,17 @@ if !exists("c_no_cformat")
47
47
endif
48
48
49
49
" cCppString: same as cString, but ends at end of line
50
- if s: ft == # " cpp" && ! exists (" cpp_no_cpp11" )
50
+ if s: ft == # " cpp" && ! exists (" cpp_no_cpp11" ) && ! exists ( " c_no_cformat " )
51
51
" ISO C++11
52
52
syn region cString start =+ \( L\| u\| u8\| U\| R\| LR\| u8R\| uR\| UR\)\= "+ skip =+ \\\\\|\\ "+ end =+ "+ contains =cSpecial,cFormat,@Spell extend
53
53
syn region cCppString start =+ \( L\| u\| u8\| U\| R\| LR\| u8R\| uR\| UR\)\= "+ skip =+ \\\\\|\\ "\|\\ $+ excludenl end =+ "+ end =' $' contains =cSpecial,cFormat,@Spell
54
- elseif s: ft == # " c" && ! exists (" c_no_c11" )
54
+ elseif s: ft == # " c" && ! exists (" c_no_c11" ) && ! exists ( " c_no_cformat " )
55
55
" ISO C99
56
56
syn region cString start =+ \% (L\| U\| u8\)\= "+ skip =+ \\\\\|\\ "+ end =+ "+ contains =cSpecial,cFormat,@Spell extend
57
57
syn region cCppString start =+ \% (L\| U\| u8\)\= "+ skip =+ \\\\\|\\ "\|\\ $+ excludenl end =+ "+ end =' $' contains =cSpecial,cFormat,@Spell
58
58
else
59
59
" older C or C++
60
+ syn match cFormat display " %%" contained
60
61
syn region cString start =+ L\= "+ skip =+ \\\\\|\\ "+ end =+ "+ contains =cSpecial,cFormat,@Spell extend
61
62
syn region cCppString start =+ L\= "+ skip =+ \\\\\|\\ "\|\\ $+ excludenl end =+ "+ end =' $' contains =cSpecial,cFormat,@Spell
62
63
endif
@@ -80,7 +81,11 @@ syn match cSpecialCharacter display "L'\\x\x\+'"
80
81
81
82
if (s: ft == # " c" && ! exists (" c_no_c11" )) || (s: ft == # " cpp" && ! exists (" cpp_no_cpp11" ))
82
83
" ISO C11 or ISO C++ 11
83
- syn region cString start =+ \% (U\| u8\=\) "+ skip =+ \\\\\|\\ "+ end =+ "+ contains =cSpecial,cFormat,@Spell extend
84
+ if exists (" c_no_cformat" )
85
+ syn region cString start =+ \% (U\| u8\=\) "+ skip =+ \\\\\|\\ "+ end =+ "+ contains =cSpecial,@Spell extend
86
+ else
87
+ syn region cString start =+ \% (U\| u8\=\) "+ skip =+ \\\\\|\\ "+ end =+ "+ contains =cSpecial,cFormat,@Spell extend
88
+ endif
84
89
syn match cCharacter " [Uu]'[^\\ ]'"
85
90
syn match cCharacter " [Uu]'[^']*'" contains =cSpecial
86
91
if exists (" c_gnu" )
@@ -330,6 +335,8 @@ if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu")
330
335
" POSIX 2001
331
336
syn keyword cConstant SIGBUS SIGPOLL SIGPROF SIGSYS SIGURG
332
337
syn keyword cConstant SIGVTALRM SIGXCPU SIGXFSZ
338
+ " non-POSIX signals
339
+ syn keyword cConstant SIGWINCH SIGINFO
333
340
" Add POSIX errors as well
334
341
syn keyword cConstant E2BIG EACCES EAGAIN EBADF EBADMSG EBUSY
335
342
syn keyword cConstant ECANCELED ECHILD EDEADLK EDOM EEXIST EFAULT
@@ -387,8 +394,13 @@ endif
387
394
syn cluster cLabelGroup contains =cUserLabel
388
395
syn match cUserCont display " ^\s *\I\i *\s *:$" contains =@cLabelGroup
389
396
syn match cUserCont display " ;\s *\I\i *\s *:$" contains =@cLabelGroup
390
- syn match cUserCont display " ^\s *\I\i *\s *:[^:]" me =e - 1 contains =@cLabelGroup
391
- syn match cUserCont display " ;\s *\I\i *\s *:[^:]" me =e - 1 contains =@cLabelGroup
397
+ if s: ft == # ' cpp'
398
+ syn match cUserCont display " ^\s *\% (class\| struct\| enum\)\@ !\I\i *\s *:[^:]" me =e - 1 contains =@cLabelGroup
399
+ syn match cUserCont display " ;\s *\% (class\| struct\| enum\)\@ !\I\i *\s *:[^:]" me =e - 1 contains =@cLabelGroup
400
+ else
401
+ syn match cUserCont display " ^\s *\I\i *\s *:[^:]" me =e - 1 contains =@cLabelGroup
402
+ syn match cUserCont display " ;\s *\I\i *\s *:[^:]" me =e - 1 contains =@cLabelGroup
403
+ endif
392
404
393
405
syn match cUserLabel display " \I\i *" contained
394
406
0 commit comments