3 " Maintainer: billiob <billiob@gmail.com>
4 " Last Change: 05/08/2011
6 " For version 5.x: Clear all syntax items
7 " For version 6.x: Quit when a syntax file was already loaded
10 elseif exists("b:current_syntax")
14 " A bunch of useful C keywords
15 syn keyword cStructure images data fonts collections group externals
16 syn keyword cStructure part parts dragable description rel1 rel2
17 syn keyword cStatement text image font fill origin size tag
18 syn keyword cStructure programs program script script_only lua_script lua_script_only styles style base
19 syn keyword cStructure spectra spectrum box
20 syn match cType "+ + +;" contained
22 syn keyword cLabel item name min max type effect
23 syn keyword cLabel mouse_events repeat_events clip_to
24 syn keyword cLabel color_class text_class x y confine
25 syn keyword cLabel state visible align step aspect aspect_preference fixed
26 syn keyword cLabel relative offset to to_x to_y normal tween
27 syn keyword cLabel border color color2 color3 font size fit align
28 syn keyword cLabel signal source action transition in target after
29 syn keyword cLabel text smooth inherit scale middle ignore_flags
30 syn keyword cLabel alias events entry_mode select_mode multiline
31 syn keyword cLabel source1 source2 source3 source4 source5 source6
32 syn keyword cLabel text_source transitions layout padding
33 syn keyword cLabel size_w size_h size_max_w size_max_h size_min_w size_min_w
34 syn keyword cLabel spread scale_hint elipsis ellipsis pointer_mode prefer
35 syn keyword cLabel precise_is_inside use_alternate_font_metrics options
36 syn keyword cLabel aspect_mode position span angle repch api
37 syn keyword cLabel external params size_range border_scale
39 syn keyword cConditional if else switch
40 syn keyword cRepeat while for do
41 syn keyword cConstant COMP RAW LOSSY USER
42 syn keyword cConstant RECT TEXT IMAGE SWALLOW TEXTBLOCK GRADIENT
43 syn keyword cConstant GROUP BOX TABLE EXTERNAL ITEM
44 syn keyword cConstant SOLID AUTOGRAB NOGRAB
45 syn keyword cConstant NONE PLAIN OUTLINE SOFT_OUTLINE SHADOW
46 syn keyword cConstant SOFT_SHADOW OUTLINE_SHADOW OUTLINE_SOFT_SHADOW
47 syn keyword cConstant FAR_SOFT_SHADOW FAR_SHADOW GLOW
48 syn keyword cConstant STATE_SET ACTION_STOP SIGNAL_EMIT
49 syn keyword cConstant SCRIPT LUA_SCRIPT
50 syn keyword cConstant DRAG_VAL_SET DRAG_VAL_STEP DRAG_VAL_PAGE
51 syn keyword cConstant LINEAR SINUSOIDAL ACCELERATE DECELERATE
52 syn keyword cConstant VERTICAL HORIZONTAL ON_HOLD BOTH EDITABLE EXPLICIT
53 syn keyword cConstant FOCUS_SET "default" NEITHER
54 syn keyword cConstant DYNAMIC STATIC
56 syn keyword cTodo contained TODO FIXME XXX
58 " cCommentGroup allows adding matches for special things in comments
59 syn cluster cCommentGroup contains=cTodo
61 " String and Character constants
62 " Highlight special characters (those which have a backslash) differently
63 syn match cSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
64 if !exists("c_no_utf")
65 syn match cSpecial display contained "\\\(u\x\{4}\|U\x\{8}\)"
67 if exists("c_no_cformat")
68 syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial
69 " cCppString: same as cString, but ends at end of line
70 syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial
72 syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([diuoxXfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained
73 syn match cFormat display "%%" contained
74 syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat
75 " cCppString: same as cString, but ends at end of line
76 syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat
79 syn match cCharacter "L\='[^\\]'"
80 syn match cCharacter "L'[^']*'" contains=cSpecial
82 syn match cSpecialError "L\='\\[^'\"?\\abefnrtv]'"
83 syn match cSpecialCharacter "L\='\\['\"?\\abefnrtv]'"
85 syn match cSpecialError "L\='\\[^'\"?\\abfnrtv]'"
86 syn match cSpecialCharacter "L\='\\['\"?\\abfnrtv]'"
88 syn match cSpecialCharacter display "L\='\\\o\{1,3}'"
89 syn match cSpecialCharacter display "'\\x\x\{1,2}'"
90 syn match cSpecialCharacter display "L'\\x\x\+'"
92 "when wanted, highlight trailing white space
93 if exists("c_space_errors")
94 if !exists("c_no_trail_space_error")
95 syn match cSpaceError display excludenl "\s\+$"
97 if !exists("c_no_tab_space_error")
98 syn match cSpaceError display " \+\t"me=e-1
102 "catch errors caused by wrong parenthesis and brackets
103 syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cCommentSkip,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom
104 if exists("c_no_bracket_error")
105 syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString
106 " cCppParen: same as cParen but ends at end-of-line; used in cDefine
107 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString
108 syn match cParenError display ")"
109 syn match cErrInParen display contained "[{}]"
111 syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString
112 " cCppParen: same as cParen but ends at end-of-line; used in cDefine
113 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString
114 syn match cParenError display "[\])]"
115 syn match cErrInParen display contained "[\]{}]"
116 syn region cBracket transparent start='\[' end=']' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString
117 " cCppBracket: same as cParen but ends at end-of-line; used in cDefine
118 syn region cCppBracket transparent start='\[' skip='\\$' excludenl end=']' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString
119 syn match cErrInBracket display contained "[);{}]"
122 "integer number, or floating point number without a dot and with "f".
124 syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal
125 " Same, but without octal error (for comments)
126 syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctal
127 syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
129 syn match cNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
130 " Flag the first zero of an octal number as something special
131 syn match cOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero
132 syn match cOctalZero display contained "\<0"
133 syn match cFloat display contained "\d\+f"
134 "floating point number, with dot, optional exponent
135 syn match cFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
136 "floating point number, starting with a dot, optional exponent
137 syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
138 "floating point number, without dot, with exponent
139 syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"
140 " flag an octal number with wrong digits
141 syn match cOctalError display contained "0\o*[89]\d*"
144 if exists("c_comment_strings")
145 " A comment can contain cString, cCharacter and cNumber.
146 " But a "*/" inside a cString in a cComment DOES end the comment! So we
147 " need to use a special type of cString: cCommentString, which also ends on
148 " "*/", and sees a "*" at the start of the line as comment again.
149 " Unfortunately this doesn't very well work for // type of comments :-(
150 syntax match cCommentSkip contained "^\s*\*\($\|\s\+\)"
151 syntax region cCommentString contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=cSpecial,cCommentSkip
152 syntax region cComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=cSpecial
153 syntax region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError
154 syntax region cComment matchgroup=cCommentStart start="/\*" matchgroup=NONE end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError
156 syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cSpaceError
157 syn region cComment matchgroup=cCommentStart start="/\*" matchgroup=NONE end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError
159 " keep a // comment separately, it terminates a preproc. conditional
160 syntax match cCommentError display "\*/"
161 syntax match cCommentStartError display "/\*"me=e-1 contained
163 syn keyword cOperator sizeof
165 syn keyword cStatement __asm__
166 syn keyword cOperator typeof __real__ __imag__
168 syn keyword cType int long short char void
169 syn keyword cType signed unsigned float double
170 if !exists("c_no_ansi") || exists("c_ansi_typedefs")
171 syn keyword cType size_t wchar_t ptrdiff_t sig_atomic_t fpos_t
172 syn keyword cType clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t
173 syn keyword cType mbstate_t wctrans_t wint_t wctype_t
175 if !exists("c_no_c99") " ISO C99
176 syn keyword cType bool complex
177 syn keyword cType int8_t int16_t int32_t int64_t
178 syn keyword cType uint8_t uint16_t uint32_t uint64_t
179 syn keyword cType int_least8_t int_least16_t int_least32_t int_least64_t
180 syn keyword cType uint_least8_t uint_least16_t uint_least32_t uint_least64_t
181 syn keyword cType int_fast8_t int_fast16_t int_fast32_t int_fast64_t
182 syn keyword cType uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t
183 syn keyword cType intptr_t uintptr_t
184 syn keyword cType intmax_t uintmax_t
187 syn keyword cType __label__ __complex__ __volatile__
190 syn keyword cStructure struct union enum typedef
191 syn keyword cStorageClass static register auto volatile extern const
193 syn keyword cStorageClass inline __attribute__
196 if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu")
198 syn keyword cConstant __GNUC__ __FUNCTION__ __PRETTY_FUNCTION__
200 syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__
201 syn keyword cConstant __STDC_VERSION__
202 syn keyword cConstant CHAR_BIT MB_LEN_MAX MB_CUR_MAX
203 syn keyword cConstant UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX
204 syn keyword cConstant CHAR_MIN INT_MIN LONG_MIN SHRT_MIN
205 syn keyword cConstant CHAR_MAX INT_MAX LONG_MAX SHRT_MAX
206 syn keyword cConstant SCHAR_MIN SINT_MIN SLONG_MIN SSHRT_MIN
207 syn keyword cConstant SCHAR_MAX SINT_MAX SLONG_MAX SSHRT_MAX
208 syn keyword cConstant FLT_RADIX FLT_ROUNDS
209 syn keyword cConstant FLT_DIG FLT_MANT_DIG FLT_EPSILON
210 syn keyword cConstant DBL_DIG DBL_MANT_DIG DBL_EPSILON
211 syn keyword cConstant LDBL_DIG LDBL_MANT_DIG LDBL_EPSILON
212 syn keyword cConstant FLT_MIN FLT_MAX FLT_MIN_EXP FLT_MAX_EXP
213 syn keyword cConstant FLT_MIN_10_EXP FLT_MAX_10_EXP
214 syn keyword cConstant DBL_MIN DBL_MAX DBL_MIN_EXP DBL_MAX_EXP
215 syn keyword cConstant DBL_MIN_10_EXP DBL_MAX_10_EXP
216 syn keyword cConstant LDBL_MIN LDBL_MAX LDBL_MIN_EXP LDBL_MAX_EXP
217 syn keyword cConstant LDBL_MIN_10_EXP LDBL_MAX_10_EXP
218 syn keyword cConstant HUGE_VAL CLOCKS_PER_SEC NULL
219 syn keyword cConstant LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY
220 syn keyword cConstant LC_NUMERIC LC_TIME
221 syn keyword cConstant SIG_DFL SIG_ERR SIG_IGN
222 syn keyword cConstant SIGABRT SIGFPE SIGILL SIGHUP SIGINT SIGSEGV SIGTERM
223 " Add POSIX signals as well...
224 syn keyword cConstant SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP
225 syn keyword cConstant SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV
226 syn keyword cConstant SIGSTOP SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU
227 syn keyword cConstant SIGUSR1 SIGUSR2
228 syn keyword cConstant _IOFBF _IOLBF _IONBF BUFSIZ EOF
229 syn keyword cConstant FOPEN_MAX FILENAME_MAX L_tmpnam
230 syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET
231 syn keyword cConstant TMP_MAX stderr stdin stdout
232 syn keyword cConstant EXIT_FAILURE EXIT_SUCCESS RAND_MAX
233 " Add POSIX errors as well
234 syn keyword cConstant E2BIG EACCES EAGAIN EBADF EBADMSG EBUSY
235 syn keyword cConstant ECANCELED ECHILD EDEADLK EDOM EEXIST EFAULT
236 syn keyword cConstant EFBIG EILSEQ EINPROGRESS EINTR EINVAL EIO EISDIR
237 syn keyword cConstant EMFILE EMLINK EMSGSIZE ENAMETOOLONG ENFILE ENODEV
238 syn keyword cConstant ENOENT ENOEXEC ENOLCK ENOMEM ENOSPC ENOSYS
239 syn keyword cConstant ENOTDIR ENOTEMPTY ENOTSUP ENOTTY ENXIO EPERM
240 syn keyword cConstant EPIPE ERANGE EROFS ESPIPE ESRCH ETIMEDOUT EXDEV
242 syn keyword cConstant M_E M_LOG2E M_LOG10E M_LN2 M_LN10 M_PI M_PI_2 M_PI_4
243 syn keyword cConstant M_1_PI M_2_PI M_2_SQRTPI M_SQRT2 M_SQRT1_2
245 if !exists("c_no_c99") " ISO C99
246 syn keyword cConstant true false
249 syn region cPreCondit start="^\s*#\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=cComment,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError
250 syn match cPreCondit display "^\s*#\s*\(else\|endif\)\>"
251 if !exists("c_no_if0")
252 syn region cCppOut start="^\s*#\s*if\s\+0\+\>" end=".\|$" contains=cCppOut2
253 syn region cCppOut2 contained start="0" end="^\s*#\s*\(endif\>\|else\>\|elif\>\)" contains=cSpaceError,cCppSkip
254 syn region cCppSkip contained start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*#\s*endif\>" contains=cSpaceError,cCppSkip
256 syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
257 syn match cIncluded display contained "<[^>]*>"
258 syn match cInclude display "^\s*#\s*include\>\s*["<]" contains=cIncluded
259 "syn match cLineSkip "\\$"
260 syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti
261 syn region cDefine start="^\s*#\s*\(define\|undef\)\>" skip="\\$" end="$" end="//"me=s-1 contains=ALLBUT,@cPreProcGroup
262 syn region cPreProc start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup
264 syn match cUserLabel display "\I\i*" contained
268 if exists("c_minlines")
269 let b:c_minlines = c_minlines
271 if !exists("c_no_if0")
272 let b:c_minlines = 50 " #if 0 constructs can be long
274 let b:c_minlines = 15 " mostly for () constructs
277 exec "syn sync ccomment cComment minlines=" . b:c_minlines
279 " Define the default highlighting.
280 " For version 5.7 and earlier: only when not done already
281 " For version 5.8 and later: only when an item doesn't have highlighting yet
282 if version >= 508 || !exists("did_c_syn_inits")
284 let did_c_syn_inits = 1
285 command -nargs=+ HiLink hi link <args>
287 command -nargs=+ HiLink hi def link <args>
290 HiLink cFormat cSpecial
291 HiLink cCppString cString
292 HiLink cCommentL cComment
293 HiLink cCommentStart cComment
295 HiLink cUserLabel Label
296 HiLink cConditional Conditional
297 HiLink cRepeat Repeat
298 HiLink cCharacter Character
299 HiLink cSpecialCharacter cSpecial
300 HiLink cNumber Number
302 HiLink cOctalZero PreProc " link this to Error if you want
304 HiLink cOctalError cError
305 HiLink cParenError cError
306 HiLink cErrInParen cError
307 HiLink cErrInBracket cError
308 HiLink cCommentError cError
309 HiLink cCommentStartError cError
310 HiLink cSpaceError cError
311 HiLink cSpecialError cError
312 HiLink cOperator Operator
313 HiLink cStructure Structure
314 HiLink cStorageClass StorageClass
315 HiLink cInclude Include
316 HiLink cPreProc PreProc
318 HiLink cIncluded cString
320 HiLink cStatement Statement
321 HiLink cPreCondit PreCondit
323 HiLink cConstant Constant
324 HiLink cCommentString cString
325 HiLink cComment2String cString
326 HiLink cCommentSkip cComment
327 HiLink cString String
328 HiLink cComment Comment
329 HiLink cSpecial SpecialChar
331 HiLink cCppSkip cCppOut
332 HiLink cCppOut2 cCppOut
333 HiLink cCppOut Comment
338 let b:current_syntax = "edc"