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