xref: /vim-8.2.3635/runtime/syntax/cs.vim (revision 95bafa29)
1" Vim syntax file
2" Language:            C#
3" Maintainer:          Nick Jensen <[email protected]>
4" Former Maintainers:  Anduin Withers <[email protected]>
5"                      Johannes Zellner <[email protected]>
6" Last Change:         2018-06-29
7" Filenames:           *.cs
8" License:             Vim (see :h license)
9" Repository:          https://github.com/nickspoons/vim-cs
10"
11" REFERENCES:
12" [1] ECMA TC39: C# Language Specification (WD13Oct01.doc)
13
14if exists("b:current_syntax")
15    finish
16endif
17
18let s:cs_cpo_save = &cpo
19set cpo&vim
20
21
22syn keyword	csType	bool byte char decimal double float int long object sbyte short string T uint ulong ushort var void dynamic
23syn keyword	csStorage	delegate enum interface namespace struct
24syn keyword	csRepeat	break continue do for foreach goto return while
25syn keyword	csConditional	else if switch
26syn keyword	csLabel	case default
27syn match	csOperatorError	display +::+
28syn match	csGlobal	display +global::+
29" user labels (see [1] 8.6 Statements)
30syn match	csLabel	display +^\s*\I\i*\s*:\([^:]\)\@=+
31syn keyword	csModifier	abstract const extern internal override private protected public readonly sealed static virtual volatile
32syn keyword	csConstant	false null true
33syn keyword	csException	try catch finally throw when
34syn keyword	csLinq	ascending by descending equals from group in into join let on orderby select where
35syn keyword	csAsync	async await
36
37syn keyword	csUnspecifiedStatement	as base checked event fixed in is lock nameof operator out params ref sizeof stackalloc this typeof unchecked unsafe using
38syn keyword	csUnsupportedStatement	add remove value
39syn keyword	csUnspecifiedKeyword	explicit implicit
40
41" Contextual Keywords
42syn match	csContextualStatement	/\<yield[[:space:]\n]\+\(return\|break\)/me=s+5
43syn match	csContextualStatement	/\<partial[[:space:]\n]\+\(class\|struct\|interface\)/me=s+7
44syn match	csContextualStatement	/\<\(get\|set\)\(;\|[[:space:]\n]*{\)/me=s+3
45syn match	csContextualStatement	/\<where\>[^:]\+:/me=s+5
46
47" Punctuation
48syn match	csBraces	"[{}\[\]]" display
49syn match	csParens	"[()]" display
50syn match	csOpSymbols	"[+\-><=]\{1,2}" display
51syn match	csOpSymbols	"[!><+\-*/]=" display
52syn match	csOpSymbols	"[!*/^]" display
53syn match	csOpSymbols	"=>" display
54syn match	csEndColon	";" display
55syn match	csLogicSymbols	"&&" display
56syn match	csLogicSymbols	"||" display
57syn match	csLogicSymbols	"?" display
58syn match	csLogicSymbols	":" display
59
60" Comments
61"
62" PROVIDES: @csCommentHook
63syn keyword	csTodo	contained TODO FIXME XXX NOTE HACK TBD
64syn region	csComment	start="/\*"  end="\*/" contains=@csCommentHook,csTodo,@Spell
65syn match	csComment	"//.*$" contains=@csCommentHook,csTodo,@Spell
66
67" xml markup inside '///' comments
68syn cluster	xmlRegionHook	add=csXmlCommentLeader
69syn cluster	xmlCdataHook	add=csXmlCommentLeader
70syn cluster	xmlStartTagHook	add=csXmlCommentLeader
71syn keyword	csXmlTag	contained Libraries Packages Types Excluded ExcludedTypeName ExcludedLibraryName
72syn keyword	csXmlTag	contained ExcludedBucketName TypeExcluded Type TypeKind TypeSignature AssemblyInfo
73syn keyword	csXmlTag	contained AssemblyName AssemblyPublicKey AssemblyVersion AssemblyCulture Base
74syn keyword	csXmlTag	contained BaseTypeName Interfaces Interface InterfaceName Attributes Attribute
75syn keyword	csXmlTag	contained AttributeName Members Member MemberSignature MemberType MemberValue
76syn keyword	csXmlTag	contained ReturnValue ReturnType Parameters Parameter MemberOfPackage
77syn keyword	csXmlTag	contained ThreadingSafetyStatement Docs devdoc example overload remarks returns summary
78syn keyword	csXmlTag	contained threadsafe value internalonly nodoc exception param permission platnote
79syn keyword	csXmlTag	contained seealso b c i pre sub sup block code note paramref see subscript superscript
80syn keyword	csXmlTag	contained list listheader item term description altcompliant altmember
81
82syn cluster xmlTagHook add=csXmlTag
83
84syn match	csXmlCommentLeader	+\/\/\/+    contained
85syn match	csXmlComment	+\/\/\/.*$+ contains=csXmlCommentLeader,@csXml,@Spell
86syn include	@csXml syntax/xml.vim
87hi def link	xmlRegion Comment
88
89
90" [1] 9.5 Pre-processing directives
91syn region	csPreCondit	start="^\s*#\s*\(define\|undef\|if\|elif\|else\|endif\|line\|error\|warning\)" skip="\\$" end="$" contains=csComment keepend
92syn region	csRegion	matchgroup=csPreCondit start="^\s*#\s*region.*$" end="^\s*#\s*endregion" transparent fold contains=TOP
93syn region	csSummary	start="^\s*/// <summary" end="^\%\(\s*///\)\@!" transparent fold keepend
94
95
96syn region	csClassType	start="@\@1<!\<class\>"hs=s+6 end="[:\n{]"me=e-1 contains=csClass
97syn region	csNewType	start="@\@1<!\<new\>"hs=s+4 end="[;\n{(<\[]"me=e-1 contains=csNew contains=csNewType
98syn region	csIsType	start=" is "hs=s+4 end="[A-Za-z0-9]\+" oneline contains=csIsAs
99syn region	csIsType	start=" as "hs=s+4 end="[A-Za-z0-9]\+" oneline contains=csIsAs
100syn keyword	csNew	new contained
101syn keyword	csClass	class contained
102syn keyword	csIsAs	is as
103
104" Strings and constants
105syn match	csSpecialError	"\\." contained
106syn match	csSpecialCharError	"[^']" contained
107" [1] 9.4.4.4 Character literals
108syn match	csSpecialChar	+\\["\\'0abfnrtvx]+ contained display
109syn match	csUnicodeNumber	+\\u\x\{4}+ contained contains=csUnicodeSpecifier display
110syn match	csUnicodeNumber	+\\U\x\{8}+ contained contains=csUnicodeSpecifier display
111syn match	csUnicodeSpecifier	+\\[uU]+ contained display
112
113syn region	csString	matchgroup=csQuote start=+"+  end=+"+ end=+$+ extend contains=csSpecialChar,csSpecialError,csUnicodeNumber,@Spell
114syn match	csCharacter	"'[^']*'" contains=csSpecialChar,csSpecialCharError display
115syn match	csCharacter	"'\\''" contains=csSpecialChar display
116syn match	csCharacter	"'[^\\]'" display
117syn match	csNumber	"\<0[0-7]*[lL]\=\>" display
118syn match	csNumber	"\<0[xX]\x\+[lL]\=\>" display
119syn match	csNumber	"\<\d\+[lL]\=\>" display
120syn match	csNumber	"\<\d\+\.\d*\%\([eE][-+]\=\d\+\)\=[fFdD]\=" display
121syn match	csNumber	"\.\d\+\%\([eE][-+]\=\d\+\)\=[fFdD]\=" display
122syn match	csNumber	"\<\d\+[eE][-+]\=\d\+[fFdD]\=\>" display
123syn match	csNumber	"\<\d\+\%\([eE][-+]\=\d\+\)\=[fFdD]\>" display
124
125syn region	csInterpolatedString	matchgroup=csQuote start=+\$"+ end=+"+ end=+$+ extend contains=csInterpolation,csEscapedInterpolation,csSpecialChar,csSpecialError,csUnicodeNumber,@Spell
126
127syn region	csInterpolation	matchgroup=csInterpolationDelimiter start=+{+ end=+}+ keepend contained contains=@csAll,csBracketed,csInterpolationAlign,csInterpolationFormat
128syn match	csEscapedInterpolation	"{{" transparent contains=NONE display
129syn match	csEscapedInterpolation	"}}" transparent contains=NONE display
130syn region	csInterpolationAlign	matchgroup=csInterpolationAlignDel start=+,+ end=+}+ end=+:+me=e-1 contained contains=csNumber,csConstant,csCharacter,csParens,csOpSymbols,csString,csBracketed display
131syn match	csInterpolationFormat	+:[^}]\+}+ contained contains=csInterpolationFormatDel display
132syn match	csInterpolationAlignDel	+,+ contained display
133syn match	csInterpolationFormatDel	+:+ contained display
134
135syn region	csVerbatimString	matchgroup=csQuote start=+@"+ end=+"+ skip=+""+ extend contains=csVerbatimQuote,@Spell
136syn match	csVerbatimQuote	+""+ contained
137syn match	csQuoteError	+@$"+he=s+2,me=s+2
138
139syn region	csInterVerbString	matchgroup=csQuote start=+\$@"+ end=+"+ skip=+""+ extend contains=csInterpolation,csEscapedInterpolation,csSpecialChar,csSpecialError,csUnicodeNumber,csVerbatimQuote,@Spell
140
141syn region	csBracketed	matchgroup=csParens start=+(+ end=+)+ contained transparent contains=@csAll,csBracketed
142
143syn cluster	csAll	contains=csCharacter,csClassType,csComment,csContextualStatement,csEndColon,csInterpolatedString,csIsType,csLabel,csLogicSymbols,csNewType,csConstant,csNumber,csOpSymbols,csOperatorError,csParens,csPreCondit,csRegion,csString,csSummary,csUnicodeNumber,csUnicodeSpecifier,csVerbatimString
144
145" The default highlighting.
146hi def link	csType	Type
147hi def link	csNewType	Type
148hi def link	csClassType	Type
149hi def link	csIsType	Type
150hi def link	csStorage	StorageClass
151hi def link	csClass	StorageClass
152hi def link	csRepeat	Repeat
153hi def link	csConditional	Conditional
154hi def link	csLabel	Label
155hi def link	csModifier	StorageClass
156hi def link	csConstant	Constant
157hi def link	csException	Exception
158hi def link	csUnspecifiedStatement	Statement
159hi def link	csUnsupportedStatement	Statement
160hi def link	csUnspecifiedKeyword	Keyword
161hi def link	csNew	Statement
162hi def link	csLinq	Statement
163hi def link	csIsAs 	Keyword
164hi def link	csAsync	Keyword
165hi def link	csContextualStatement	Statement
166hi def link	csOperatorError	Error
167hi def link	csInterfaceDeclaration	Include
168
169hi def link	csTodo	Todo
170hi def link	csComment	Comment
171
172hi def link	csEndColon	Statement
173hi def link	csOpSymbols	Operator
174hi def link	csLogicSymbols	Boolean
175hi def link	csBraces	Function
176hi def link	csParens	Operator
177
178hi def link	csSpecialError	Error
179hi def link	csSpecialCharError	Error
180hi def link	csString	String
181hi def link	csQuote	String
182hi def link	csQuoteError	Error
183hi def link	csInterpolatedString	String
184hi def link	csVerbatimString	String
185hi def link	csInterVerbString	String
186hi def link	csVerbatimQuote	SpecialChar
187hi def link	csPreCondit	PreCondit
188hi def link	csCharacter	Character
189hi def link	csSpecialChar	SpecialChar
190hi def link	csNumber	Number
191hi def link	csUnicodeNumber	SpecialChar
192hi def link	csUnicodeSpecifier	SpecialChar
193hi def link	csInterpolationDelimiter	Delimiter
194hi def link	csInterpolationAlignDel	csInterpolationDelimiter
195hi def link	csInterpolationFormat	csInterpolationDelimiter
196hi def link	csInterpolationFormatDel	csInterpolationDelimiter
197
198" xml markup
199hi def link	csXmlCommentLeader	Comment
200hi def link	csXmlComment	Comment
201hi def link	csXmlTag	Statement
202
203let b:current_syntax = "cs"
204
205let &cpo = s:cs_cpo_save
206unlet s:cs_cpo_save
207
208" vim: vts=16,28
209