3 " Maintainer: Anduin Withers <awithers@anduin.com>
4 " Former Maintainer: Johannes Zellner <johannes@zellner.org>
5 " Last Change: Sun Apr 30 19:26:18 PDT 2006
7 " $Id: cs.vim,v 1.4 2006/05/03 21:20:02 vimboss Exp $
10 " [1] ECMA TC39: C# Language Specification (WD13Oct01.doc)
12 if exists("b:current_syntax")
16 let s:cs_cpo_save = &cpo
21 syn keyword csType bool byte char decimal double float int long object sbyte short string uint ulong ushort void
23 syn keyword csStorage class delegate enum interface namespace struct
24 " repeat / condition / label
25 syn keyword csRepeat break continue do for foreach goto return while
26 syn keyword csConditional else if switch
27 syn keyword csLabel case default
28 " there's no :: operator in C#
29 syn match csOperatorError display +::+
30 " user labels (see [1] 8.6 Statements)
31 syn match csLabel display +^\s*\I\i*\s*:\([^:]\)\@=+
33 syn keyword csModifier abstract const extern internal override private protected public readonly sealed static virtual volatile
35 syn keyword csConstant false null true
37 syn keyword csException try catch finally throw
40 syn keyword csUnspecifiedStatement as base checked event fixed in is lock new operator out params ref sizeof stackalloc this typeof unchecked unsafe using
42 syn keyword csUnsupportedStatement add remove value
44 syn keyword csUnspecifiedKeyword explicit implicit
48 syn match csContextualStatement /\<yield[[:space:]\n]\+\(return\|break\)/me=s+5
49 syn match csContextualStatement /\<partial[[:space:]\n]\+\(class\|struct\|interface\)/me=s+7
50 syn match csContextualStatement /\<\(get\|set\)[[:space:]\n]*{/me=s+3
51 syn match csContextualStatement /\<where\>[^:]\+:/me=s+5
55 " PROVIDES: @csCommentHook
57 " TODO: include strings ?
59 syn keyword csTodo contained TODO FIXME XXX NOTE
60 syn region csComment start="/\*" end="\*/" contains=@csCommentHook,csTodo,@Spell
61 syn match csComment "//.*$" contains=@csCommentHook,csTodo,@Spell
63 " xml markup inside '///' comments
64 syn cluster xmlRegionHook add=csXmlCommentLeader
65 syn cluster xmlCdataHook add=csXmlCommentLeader
66 syn cluster xmlStartTagHook add=csXmlCommentLeader
67 syn keyword csXmlTag contained Libraries Packages Types Excluded ExcludedTypeName ExcludedLibraryName
68 syn keyword csXmlTag contained ExcludedBucketName TypeExcluded Type TypeKind TypeSignature AssemblyInfo
69 syn keyword csXmlTag contained AssemblyName AssemblyPublicKey AssemblyVersion AssemblyCulture Base
70 syn keyword csXmlTag contained BaseTypeName Interfaces Interface InterfaceName Attributes Attribute
71 syn keyword csXmlTag contained AttributeName Members Member MemberSignature MemberType MemberValue
72 syn keyword csXmlTag contained ReturnValue ReturnType Parameters Parameter MemberOfPackage
73 syn keyword csXmlTag contained ThreadingSafetyStatement Docs devdoc example overload remarks returns summary
74 syn keyword csXmlTag contained threadsafe value internalonly nodoc exception param permission platnote
75 syn keyword csXmlTag contained seealso b c i pre sub sup block code note paramref see subscript superscript
76 syn keyword csXmlTag contained list listheader item term description altcompliant altmember
78 syn cluster xmlTagHook add=csXmlTag
80 syn match csXmlCommentLeader +\/\/\/+ contained
81 syn match csXmlComment +\/\/\/.*$+ contains=csXmlCommentLeader,@csXml
82 syntax include @csXml <sfile>:p:h/xml.vim
83 hi def link xmlRegion Comment
86 " [1] 9.5 Pre-processing directives
87 syn region csPreCondit
88 \ start="^\s*#\s*\(define\|undef\|if\|elif\|else\|endif\|line\|error\|warning\)"
89 \ skip="\\$" end="$" contains=csComment keepend
90 syn region csRegion matchgroup=csPreCondit start="^\s*#\s*region.*$"
91 \ end="^\s*#\s*endregion" transparent fold contains=TOP
95 " Strings and constants
96 syn match csSpecialError contained "\\."
97 syn match csSpecialCharError contained "[^']"
98 " [1] 9.4.4.4 Character literals
99 syn match csSpecialChar contained +\\["\\'0abfnrtvx]+
101 syn match csUnicodeNumber +\\\(u\x\{4}\|U\x\{8}\)+ contained contains=csUnicodeSpecifier
102 syn match csUnicodeSpecifier +\\[uU]+ contained
103 syn region csVerbatimString start=+@"+ end=+"+ end=+$+ skip=+""+ contains=csVerbatimSpec,@Spell
104 syn match csVerbatimSpec +@"+he=s+1 contained
105 syn region csString start=+"+ end=+"+ end=+$+ contains=csSpecialChar,csSpecialError,csUnicodeNumber,@Spell
106 syn match csCharacter "'[^']*'" contains=csSpecialChar,csSpecialCharError
107 syn match csCharacter "'\\''" contains=csSpecialChar
108 syn match csCharacter "'[^\\]'"
109 syn match csNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
110 syn match csNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
111 syn match csNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
112 syn match csNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
114 " The default highlighting.
115 hi def link csType Type
116 hi def link csStorage StorageClass
117 hi def link csRepeat Repeat
118 hi def link csConditional Conditional
119 hi def link csLabel Label
120 hi def link csModifier StorageClass
121 hi def link csConstant Constant
122 hi def link csException Exception
123 hi def link csUnspecifiedStatement Statement
124 hi def link csUnsupportedStatement Statement
125 hi def link csUnspecifiedKeyword Keyword
126 hi def link csContextualStatement Statement
127 hi def link csOperatorError Error
129 hi def link csTodo Todo
130 hi def link csComment Comment
132 hi def link csSpecialError Error
133 hi def link csSpecialCharError Error
134 hi def link csString String
135 hi def link csVerbatimString String
136 hi def link csVerbatimSpec SpecialChar
137 hi def link csPreCondit PreCondit
138 hi def link csCharacter Character
139 hi def link csSpecialChar SpecialChar
140 hi def link csNumber Number
141 hi def link csUnicodeNumber SpecialChar
142 hi def link csUnicodeSpecifier SpecialChar
145 hi def link csXmlCommentLeader Comment
146 hi def link csXmlComment Comment
147 hi def link csXmlTag Statement
149 let b:current_syntax = "cs"
151 let &cpo = s:cs_cpo_save