11" Vim syntax file
22" Language: C
33" Maintainer: Bram Moolenaar <[email protected] >4- " Last Change: 2013 Jun 06
4+ " Last Change: 2013 Jul 05
55
66" Quit when a (custom) syntax file was already loaded
77if exists (" b:current_syntax" )
1111let s: cpo_save = &cpo
1212set cpo &vim
1313
14+ let s: ft = matchstr (&ft , ' ^\([^.]\)\+' )
15+
1416" A bunch of useful C keywords
1517syn keyword cStatement goto break return continue asm
1618syn keyword cLabel case default
@@ -110,7 +112,7 @@ endif
110112" But avoid matching <::.
111113syn cluster cParenGroup contains =cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom
112114if exists (" c_no_curly_error" )
113- if & filetype == # ' cpp' && ! exists (" cpp_no_cpp11" )
115+ if s: ft == # ' cpp' && ! exists (" cpp_no_cpp11" )
114116 syn region cParen transparent start =' (' end =' )' contains =ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell
115117 " cCppParen: same as cParen but ends at end-of-line; used in cDefine
116118 syn region cCppParen transparent start =' (' skip =' \\ $' excludenl end =' )' end =' $' contained contains =ALLBUT,@cParenGroup,cParen,cString,@Spell
@@ -124,7 +126,7 @@ if exists("c_no_curly_error")
124126 syn match cErrInParen display contained " ^[{}]\| ^<%\| ^%>"
125127 endif
126128elseif exists (" c_no_bracket_error" )
127- if & filetype == # ' cpp' && ! exists (" cpp_no_cpp11" )
129+ if s: ft == # ' cpp' && ! exists (" cpp_no_cpp11" )
128130 syn region cParen transparent start =' (' end =' )' contains =ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell
129131 " cCppParen: same as cParen but ends at end-of-line; used in cDefine
130132 syn region cCppParen transparent start =' (' skip =' \\ $' excludenl end =' )' end =' $' contained contains =ALLBUT,@cParenGroup,cParen,cString,@Spell
@@ -138,7 +140,7 @@ elseif exists("c_no_bracket_error")
138140 syn match cErrInParen display contained " [{}]\| <%\| %>"
139141 endif
140142else
141- if & filetype == # ' cpp' && ! exists (" cpp_no_cpp11" )
143+ if s: ft == # ' cpp' && ! exists (" cpp_no_cpp11" )
142144 syn region cParen transparent start =' (' end =' )' contains =ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell
143145 " cCppParen: same as cParen but ends at end-of-line; used in cDefine
144146 syn region cCppParen transparent start =' (' skip =' \\ $' excludenl end =' )' end =' $' contained contains =ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell
158160 syn match cErrInBracket display contained " [);{}]\| <%\| %>"
159161endif
160162
161- if & filetype == # ' c' || exists (" cpp_no_cpp11" )
163+ if s: ft == # ' c' || exists (" cpp_no_cpp11" )
162164 syn region cBadBlock keepend start =" {" end =" }" contained containedin =cParen,cBracket,cBadBlock transparent fold
163165endif
164166
@@ -370,7 +372,7 @@ syn region cPreProc start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>
370372
371373" Highlight User Labels
372374syn 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
373- if & filetype == # ' c' || exists (" cpp_no_cpp11" )
375+ if s: ft == # ' c' || exists (" cpp_no_cpp11" )
374376 syn region cMulti transparent start =' ?' skip =' ::' end =' :' contains =ALLBUT,@cMultiGroup,@Spell
375377endif
376378" Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
@@ -457,6 +459,8 @@ hi def link cCppOut Comment
457459
458460let b: current_syntax = " c"
459461
462+ unlet s: ft
463+
460464let &cpo = s: cpo_save
461465unlet s: cpo_save
462466" vim: ts = 8
0 commit comments