fyrenmoo@2671: " Vim syntax file fyrenmoo@2671: " Language: SourcePawn fyrenmoo@2671: " Generated by vimsyntax.pl fyrenmoo@2671: fyrenmoo@2671: " Quit when a (custom) syntax file was already loaded fyrenmoo@2671: "if exists("b:current_syntax") fyrenmoo@2671: " finish fyrenmoo@2671: "endif fyrenmoo@2671: fyrenmoo@2671: " A bunch of useful C keywords fyrenmoo@2671: syn keyword cStatement goto break return continue assert state sleep exit fyrenmoo@2671: syn keyword cLabel case default fyrenmoo@2671: syn keyword cConditional if else switch fyrenmoo@2671: syn keyword cRepeat while for do fyrenmoo@2671: fyrenmoo@2671: syn keyword cTodo contained TODO FIXME XXX fyrenmoo@2671: fyrenmoo@2671: " cCommentGroup allows adding matches for special things in comments fyrenmoo@2671: syn cluster cCommentGroup contains=cTodo fyrenmoo@2671: fyrenmoo@2671: " String and Character constants fyrenmoo@2671: " Highlight special characters (those which have a backslash) differently fyrenmoo@2671: syn match cSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" fyrenmoo@2671: if !exists("c_no_utf") fyrenmoo@2671: syn match cSpecial display contained "\\\(u\x\{4}\|U\x\{8}\)" fyrenmoo@2671: endif fyrenmoo@2671: if exists("c_no_cformat") fyrenmoo@2671: syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell fyrenmoo@2671: " cCppString: same as cString, but ends at end of line fyrenmoo@2671: syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,@Spell fyrenmoo@2671: else fyrenmoo@2671: if !exists("c_no_c99") " ISO C99 fyrenmoo@2671: syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained fyrenmoo@2671: else fyrenmoo@2671: syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained fyrenmoo@2671: endif fyrenmoo@2671: syn match cFormat display "%%" contained fyrenmoo@2671: syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell fyrenmoo@2671: " cCppString: same as cString, but ends at end of line fyrenmoo@2671: syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell fyrenmoo@2671: endif fyrenmoo@2671: fyrenmoo@2671: syn match cCharacter "L\='[^\\]'" fyrenmoo@2671: syn match cCharacter "L'[^']*'" contains=cSpecial fyrenmoo@2671: if exists("c_gnu") fyrenmoo@2671: syn match cSpecialError "L\='\\[^'\"?\\abefnrtv]'" fyrenmoo@2671: syn match cSpecialCharacter "L\='\\['\"?\\abefnrtv]'" fyrenmoo@2671: else fyrenmoo@2671: syn match cSpecialError "L\='\\[^'\"?\\abfnrtv]'" fyrenmoo@2671: syn match cSpecialCharacter "L\='\\['\"?\\abfnrtv]'" fyrenmoo@2671: endif fyrenmoo@2671: syn match cSpecialCharacter display "L\='\\\o\{1,3}'" fyrenmoo@2671: syn match cSpecialCharacter display "'\\x\x\{1,2}'" fyrenmoo@2671: syn match cSpecialCharacter display "L'\\x\x\+'" fyrenmoo@2671: fyrenmoo@2671: "when wanted, highlight trailing white space fyrenmoo@2671: if exists("c_space_errors") fyrenmoo@2671: if !exists("c_no_trail_space_error") fyrenmoo@2671: syn match cSpaceError display excludenl "\s\+$" fyrenmoo@2671: endif fyrenmoo@2671: if !exists("c_no_tab_space_error") fyrenmoo@2671: syn match cSpaceError display " \+\t"me=e-1 fyrenmoo@2671: endif fyrenmoo@2671: endif fyrenmoo@2671: fyrenmoo@2671: " This should be before cErrInParen to avoid problems with #define ({ xxx }) fyrenmoo@2671: syntax region cBlock start="{" end="}" transparent fold fyrenmoo@2671: fyrenmoo@2671: "catch errors caused by wrong parenthesis and brackets fyrenmoo@2671: " also accept <% for {, %> for }, <: for [ and :> for ] (C99) fyrenmoo@2671: " But avoid matching <::. fyrenmoo@2671: syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cCommentSkip,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cNumbersCom fyrenmoo@2671: if exists("c_no_curly_error") fyrenmoo@2671: syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell fyrenmoo@2671: " cCppParen: same as cParen but ends at end-of-line; used in cDefine fyrenmoo@2671: syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell fyrenmoo@2671: syn match cParenError display ")" fyrenmoo@2671: syn match cErrInParen display contained "^[{}]\|^<%\|^%>" fyrenmoo@2671: elseif exists("c_no_bracket_error") fyrenmoo@2671: syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell fyrenmoo@2671: " cCppParen: same as cParen but ends at end-of-line; used in cDefine fyrenmoo@2671: syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell fyrenmoo@2671: syn match cParenError display ")" fyrenmoo@2671: syn match cErrInParen display contained "[{}]\|<%\|%>" fyrenmoo@2671: else fyrenmoo@2671: syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell fyrenmoo@2671: " cCppParen: same as cParen but ends at end-of-line; used in cDefine fyrenmoo@2671: syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell fyrenmoo@2671: syn match cParenError display "[\])]" fyrenmoo@2671: syn match cErrInParen display contained "[\]{}]\|<%\|%>" fyrenmoo@2671: syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString,@Spell fyrenmoo@2671: " cCppBracket: same as cParen but ends at end-of-line; used in cDefine fyrenmoo@2671: syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell fyrenmoo@2671: syn match cErrInBracket display contained "[);{}]\|<%\|%>" fyrenmoo@2671: endif fyrenmoo@2671: fyrenmoo@2671: "integer number, or floating point number without a dot and with "f". fyrenmoo@2671: syn case ignore fyrenmoo@2671: syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat fyrenmoo@2671: " Same (for comments) fyrenmoo@2671: syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat fyrenmoo@2671: syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" fyrenmoo@2671: "hex number fyrenmoo@2671: syn match cNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" fyrenmoo@2671: syn match cFloat display contained "\d\+f" fyrenmoo@2671: "floating point number, with dot, optional exponent fyrenmoo@2671: syn match cFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=" fyrenmoo@2671: "floating point number, starting with a dot, optional exponent fyrenmoo@2671: syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" fyrenmoo@2671: "floating point number, without dot, with exponent fyrenmoo@2671: syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" fyrenmoo@2671: if !exists("c_no_c99") fyrenmoo@2671: "hexadecimal floating point number, optional leading digits, with dot, with exponent fyrenmoo@2671: syn match cFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>" fyrenmoo@2671: "hexadecimal floating point number, with leading digits, optional dot, with exponent fyrenmoo@2671: syn match cFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>" fyrenmoo@2671: endif fyrenmoo@2671: fyrenmoo@2671: syn case match fyrenmoo@2671: fyrenmoo@2671: if exists("c_comment_strings") fyrenmoo@2671: " A comment can contain cString, cCharacter and cNumber. fyrenmoo@2671: " But a "*/" inside a cString in a cComment DOES end the comment! So we fyrenmoo@2671: " need to use a special type of cString: cCommentString, which also ends on fyrenmoo@2671: " "*/", and sees a "*" at the start of the line as comment again. fyrenmoo@2671: " Unfortunately this doesn't very well work for // type of comments :-( fyrenmoo@2671: syntax match cCommentSkip contained "^\s*\*\($\|\s\+\)" fyrenmoo@2671: syntax region cCommentString contained start=+L\=\\\@" skip="\\$" end="$" end="//"me=s-1 contains=cComment,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError fyrenmoo@2671: syn match cPreCondit display "^\s*\(%:\|#\)\s*\(else\|endif\)\>" fyrenmoo@2671: if !exists("c_no_if0") fyrenmoo@2671: if !exists("c_no_if0_fold") fyrenmoo@2671: syn region cCppOut start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2 fold fyrenmoo@2671: else fyrenmoo@2671: syn region cCppOut start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2 fyrenmoo@2671: endif fyrenmoo@2671: syn region cCppOut2 contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=cSpaceError,cCppSkip fyrenmoo@2671: syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip fyrenmoo@2671: endif fyrenmoo@2671: syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ fyrenmoo@2671: syn match cIncluded display contained "<[^>]*>" fyrenmoo@2671: syn match cInclude display "^\s*\(%:\|#\)\s*\(include\>\|tryinclude\>\)\s*["<]" contains=cIncluded fyrenmoo@2671: "syn match cLineSkip "\\$" fyrenmoo@2671: 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 fyrenmoo@2671: syn region cDefine start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" end="//"me=s-1 keepend contains=ALLBUT,@cPreProcGroup,@Spell fyrenmoo@2671: syn region cPreProc start="^\s*\(%:\|#\)\s*\(assert\>\|emit\>\|endinput\>\|endscript\>\|pragma\>\|line\>\|section\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell fyrenmoo@2671: fyrenmoo@2671: " Highlight User Labels fyrenmoo@2671: syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cNumbersCom,cCppParen,cCppBracket,cCppString fyrenmoo@2671: syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell fyrenmoo@2671: " Avoid matching foo::bar() in C++ by requiring that the next char is not ':' fyrenmoo@2671: syn cluster cLabelGroup contains=cUserLabel fyrenmoo@2671: syn match cUserCont display "^\s*\I\i*\s*:$" contains=@cLabelGroup fyrenmoo@2671: syn match cUserCont display ";\s*\I\i*\s*:$" contains=@cLabelGroup fyrenmoo@2671: syn match cUserCont display "^\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup fyrenmoo@2671: syn match cUserCont display ";\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup fyrenmoo@2671: fyrenmoo@2671: syn match cUserLabel display "\I\i*" contained fyrenmoo@2671: fyrenmoo@2671: " C++ extentions fyrenmoo@2671: syn keyword cppStatement new decl fyrenmoo@2671: syn keyword cppAccess public fyrenmoo@2671: syn keyword cppOperator operator fyrenmoo@2671: fyrenmoo@2671: if exists("c_minlines") fyrenmoo@2671: let b:c_minlines = c_minlines fyrenmoo@2671: else fyrenmoo@2671: if !exists("c_no_if0") fyrenmoo@2671: let b:c_minlines = 50 " #if 0 constructs can be long fyrenmoo@2671: else fyrenmoo@2671: let b:c_minlines = 15 " mostly for () constructs fyrenmoo@2671: endif fyrenmoo@2671: endif fyrenmoo@2671: exec "syn sync ccomment cComment minlines=" . b:c_minlines fyrenmoo@2671: fyrenmoo@2671: " Define the default highlighting. fyrenmoo@2671: " Only used when an item doesn't have highlighting yet fyrenmoo@2671: hi def link cFormat cSpecial fyrenmoo@2671: hi def link cCppString cString fyrenmoo@2671: hi def link cCommentL cComment fyrenmoo@2671: hi def link cCommentStart cComment fyrenmoo@2671: hi def link cLabel Label fyrenmoo@2671: hi def link cUserLabel Label fyrenmoo@2671: hi def link cConditional Conditional fyrenmoo@2671: hi def link cRepeat Repeat fyrenmoo@2671: hi def link cCharacter Character fyrenmoo@2671: hi def link cSpecialCharacter cSpecial fyrenmoo@2671: hi def link cNumber Number fyrenmoo@2671: hi def link cFloat Float fyrenmoo@2671: hi def link cParenError cError fyrenmoo@2671: hi def link cErrInParen cError fyrenmoo@2671: hi def link cErrInBracket cError fyrenmoo@2671: hi def link cCommentError cError fyrenmoo@2671: hi def link cCommentStartError cError fyrenmoo@2671: hi def link cSpaceError cError fyrenmoo@2671: hi def link cSpecialError cError fyrenmoo@2671: hi def link cOperator Operator fyrenmoo@2671: hi def link cStructure Structure fyrenmoo@2671: hi def link cStorageClass StorageClass fyrenmoo@2671: hi def link cInclude Include fyrenmoo@2671: hi def link cPreProc PreProc fyrenmoo@2671: hi def link cDefine Macro fyrenmoo@2671: hi def link cIncluded cString fyrenmoo@2671: hi def link cError Error fyrenmoo@2671: hi def link cStatement Statement fyrenmoo@2671: hi def link cPreCondit PreCondit fyrenmoo@2671: hi def link cTag Type fyrenmoo@2671: hi def link cConstant Constant fyrenmoo@2671: hi def link cCommentString cString fyrenmoo@2671: hi def link cComment2String cString fyrenmoo@2671: hi def link cCommentSkip cComment fyrenmoo@2671: hi def link cString String fyrenmoo@2671: hi def link cComment Comment fyrenmoo@2671: hi def link cSpecial SpecialChar fyrenmoo@2671: hi def link cTodo Todo fyrenmoo@2671: hi def link cCppSkip cCppOut fyrenmoo@2671: hi def link cCppOut2 cCppOut fyrenmoo@2671: hi def link cCppOut Comment fyrenmoo@2671: fyrenmoo@2671: hi def link cppAccess cppStatement fyrenmoo@2671: hi def link cppOperator Operator fyrenmoo@2671: hi def link cppStatement Statement fyrenmoo@2671: fyrenmoo@2671: hi def link cFunction Function fyrenmoo@2671: hi def link cForward Function fyrenmoo@2671: fyrenmoo@2671: let b:current_syntax = "sourcepawn" fyrenmoo@2671: fyrenmoo@2671: " vim: ts=8