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