blob: 6a61ed261ec4913e125ef0dc6a8e3abb70742dcf [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: C#
3" Maintainer: Johannes Zellner <johannes@zellner.org>
Bram Moolenaar551dbcc2006-04-25 22:13:59 +00004" Last Change: Mo, 24 Apr 2006 10:11:07 CEST
Bram Moolenaar071d4272004-06-13 20:20:40 +00005" Filenames: *.cs
6" $Id$
7"
8" REFERENCES:
9" [1] ECMA TC39: C# Language Specification (WD13Oct01.doc)
10
11if exists("b:current_syntax")
12 finish
13endif
14
15let s:cs_cpo_save = &cpo
16set cpo&vim
17
18
19" type
20syn keyword csType bool byte char decimal double float int long object sbyte short string uint ulong ushort void
21" storage
22syn keyword csStorage class delegate enum interface namespace struct
Bram Moolenaar551dbcc2006-04-25 22:13:59 +000023" repeat / condition / label
Bram Moolenaar071d4272004-06-13 20:20:40 +000024syn keyword csRepeat break continue do for foreach goto return while
25syn keyword csConditional else if switch
26syn keyword csLabel case default
27" there's no :: operator in C#
28syn match csOperatorError display +::+
29" user labels (see [1] 8.6 Statements)
30syn match csLabel display +^\s*\I\i*\s*:\([^:]\)\@=+
31" modifier
32syn keyword csModifier abstract const extern internal override private protected public readonly sealed static virtual volatile
33" constant
34syn keyword csConstant false null true
35" exception
36syn keyword csException try catch finally throw
37
38" TODO:
39syn keyword csUnspecifiedStatement as base checked event fixed in is lock new operator out params ref sizeof stackalloc this typeof unchecked unsafe using
40" TODO:
41syn keyword csUnsupportedStatement get set add remove value
42" TODO:
43syn keyword csUnspecifiedKeyword explicit implicit
44
45
46
47" Comments
48"
49" PROVIDES: @csCommentHook
50"
51" TODO: include strings ?
52"
53syn keyword csTodo contained TODO FIXME XXX NOTE
Bram Moolenaar551dbcc2006-04-25 22:13:59 +000054syn region csComment start="/\*" end="\*/" contains=@csCommentHook,csTodo,@Spell
55syn match csComment "//.*$" contains=@csCommentHook,csTodo,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +000056
57" xml markup inside '///' comments
58syn cluster xmlRegionHook add=csXmlCommentLeader
59syn cluster xmlCdataHook add=csXmlCommentLeader
60syn cluster xmlStartTagHook add=csXmlCommentLeader
61syn keyword csXmlTag contained Libraries Packages Types Excluded ExcludedTypeName ExcludedLibraryName
62syn keyword csXmlTag contained ExcludedBucketName TypeExcluded Type TypeKind TypeSignature AssemblyInfo
63syn keyword csXmlTag contained AssemblyName AssemblyPublicKey AssemblyVersion AssemblyCulture Base
64syn keyword csXmlTag contained BaseTypeName Interfaces Interface InterfaceName Attributes Attribute
65syn keyword csXmlTag contained AttributeName Members Member MemberSignature MemberType MemberValue
66syn keyword csXmlTag contained ReturnValue ReturnType Parameters Parameter MemberOfPackage
67syn keyword csXmlTag contained ThreadingSafetyStatement Docs devdoc example overload remarks returns summary
68syn keyword csXmlTag contained threadsafe value internalonly nodoc exception param permission platnote
69syn keyword csXmlTag contained seealso b c i pre sub sup block code note paramref see subscript superscript
70syn keyword csXmlTag contained list listheader item term description altcompliant altmember
71
72syn cluster xmlTagHook add=csXmlTag
73
74syn match csXmlCommentLeader +\/\/\/+ contained
75syn match csXmlComment +\/\/\/.*$+ contains=csXmlCommentLeader,@csXml
76syntax include @csXml <sfile>:p:h/xml.vim
77hi def link xmlRegion Comment
78
79
80" [1] 9.5 Pre-processing directives
81syn region csPreCondit
82 \ start="^\s*#\s*\(define\|undef\|if\|elif\|else\|endif\|line\|error\|warning\|region\|endregion\)"
83 \ skip="\\$" end="$" contains=csComment keepend
84
85
86
87" Strings and constants
88syn match csSpecialError contained "\\."
89syn match csSpecialCharError contained "[^']"
90" [1] 9.4.4.4 Character literals
91syn match csSpecialChar contained +\\["\\'0abfnrtvx]+
92" unicode characters
93syn match csUnicodeNumber +\\\(u\x\{4}\|U\x\{8}\)+ contained contains=csUnicodeSpecifier
94syn match csUnicodeSpecifier +\\[uU]+ contained
Bram Moolenaar551dbcc2006-04-25 22:13:59 +000095syn region csVerbatimString start=+@"+ end=+"+ end=+$+ skip=+""+ contains=csVerbatimSpec,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +000096syn match csVerbatimSpec +@"+he=s+1 contained
Bram Moolenaar551dbcc2006-04-25 22:13:59 +000097syn region csString start=+"+ end=+"+ end=+$+ contains=csSpecialChar,csSpecialError,csUnicodeNumber,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +000098syn match csCharacter "'[^']*'" contains=csSpecialChar,csSpecialCharError
99syn match csCharacter "'\\''" contains=csSpecialChar
100syn match csCharacter "'[^\\]'"
101syn match csNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
102syn match csNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
103syn match csNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
104syn match csNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
105
106" The default highlighting.
107hi def link csType Type
108hi def link csStorage StorageClass
109hi def link csRepeat Repeat
110hi def link csConditional Conditional
111hi def link csLabel Label
112hi def link csModifier StorageClass
113hi def link csConstant Constant
114hi def link csException Exception
115hi def link csUnspecifiedStatement Statement
116hi def link csUnsupportedStatement Statement
117hi def link csUnspecifiedKeyword Keyword
118hi def link csOperatorError Error
119
120hi def link csTodo Todo
121hi def link csComment Comment
122
123hi def link csSpecialError Error
124hi def link csSpecialCharError Error
125hi def link csString String
126hi def link csVerbatimString String
127hi def link csVerbatimSpec SpecialChar
128hi def link csPreCondit PreCondit
129hi def link csCharacter Character
130hi def link csSpecialChar SpecialChar
131hi def link csNumber Number
132hi def link csUnicodeNumber SpecialChar
133hi def link csUnicodeSpecifier SpecialChar
134
135" xml markup
136hi def link csXmlCommentLeader Comment
137hi def link csXmlComment Comment
138hi def link csXmlTag Statement
139
140let b:current_syntax = "cs"
141
142let &cpo = s:cs_cpo_save
143unlet s:cs_cpo_save
144
145" vim: ts=8