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>
|
19303
|
6 " Last Change: 2020-01-27
|
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
|
19303
|
100 " Since syntax/xml.vim contains `syn spell toplevel`, we need to set it back to `default` here.
|
|
101 syn spell default
|
7
|
102
|
|
103 " [1] 9.5 Pre-processing directives
|
14372
|
104 syn region csPreCondit start="^\s*#\s*\(define\|undef\|if\|elif\|else\|endif\|line\|error\|warning\)" skip="\\$" end="$" contains=csComment keepend
|
|
105 syn region csRegion matchgroup=csPreCondit start="^\s*#\s*region.*$" end="^\s*#\s*endregion" transparent fold contains=TOP
|
|
106 syn region csSummary start="^\s*/// <summary" end="^\%\(\s*///\)\@!" transparent fold keepend
|
7
|
107
|
|
108
|
14372
|
109 syn region csClassType start="@\@1<!\<class\>"hs=s+6 end="[:\n{]"me=e-1 contains=csClass
|
17667
|
110 " csUserType may be defined by user scripts/plugins - it should be contained in csNewType
|
|
111 syn region csNewType start="@\@1<!\<new\>"hs=s+4 end="[;\n{(<\[]"me=e-1 contains=csNew,csUserType
|
14372
|
112 syn region csIsType start=" is "hs=s+4 end="[A-Za-z0-9]\+" oneline contains=csIsAs
|
|
113 syn region csIsType start=" as "hs=s+4 end="[A-Za-z0-9]\+" oneline contains=csIsAs
|
|
114 syn keyword csNew new contained
|
|
115 syn keyword csClass class contained
|
|
116 syn keyword csIsAs is as
|
7
|
117
|
|
118 " Strings and constants
|
14372
|
119 syn match csSpecialError "\\." contained
|
|
120 syn match csSpecialCharError "[^']" contained
|
7
|
121 " [1] 9.4.4.4 Character literals
|
14372
|
122 syn match csSpecialChar +\\["\\'0abfnrtvx]+ contained display
|
|
123 syn match csUnicodeNumber +\\u\x\{4}+ contained contains=csUnicodeSpecifier display
|
|
124 syn match csUnicodeNumber +\\U\x\{8}+ contained contains=csUnicodeSpecifier display
|
|
125 syn match csUnicodeSpecifier +\\[uU]+ contained display
|
|
126
|
|
127 syn region csString matchgroup=csQuote start=+"+ end=+"+ end=+$+ extend contains=csSpecialChar,csSpecialError,csUnicodeNumber,@Spell
|
|
128 syn match csCharacter "'[^']*'" contains=csSpecialChar,csSpecialCharError display
|
|
129 syn match csCharacter "'\\''" contains=csSpecialChar display
|
|
130 syn match csCharacter "'[^\\]'" display
|
|
131 syn match csNumber "\<0[0-7]*[lL]\=\>" display
|
|
132 syn match csNumber "\<0[xX]\x\+[lL]\=\>" display
|
|
133 syn match csNumber "\<\d\+[lL]\=\>" display
|
|
134 syn match csNumber "\<\d\+\.\d*\%\([eE][-+]\=\d\+\)\=[fFdD]\=" display
|
|
135 syn match csNumber "\.\d\+\%\([eE][-+]\=\d\+\)\=[fFdD]\=" display
|
|
136 syn match csNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>" display
|
|
137 syn match csNumber "\<\d\+\%\([eE][-+]\=\d\+\)\=[fFdD]\>" display
|
|
138
|
|
139 syn region csInterpolatedString matchgroup=csQuote start=+\$"+ end=+"+ end=+$+ extend contains=csInterpolation,csEscapedInterpolation,csSpecialChar,csSpecialError,csUnicodeNumber,@Spell
|
|
140
|
|
141 syn region csInterpolation matchgroup=csInterpolationDelimiter start=+{+ end=+}+ keepend contained contains=@csAll,csBracketed,csInterpolationAlign,csInterpolationFormat
|
|
142 syn match csEscapedInterpolation "{{" transparent contains=NONE display
|
|
143 syn match csEscapedInterpolation "}}" transparent contains=NONE display
|
|
144 syn region csInterpolationAlign matchgroup=csInterpolationAlignDel start=+,+ end=+}+ end=+:+me=e-1 contained contains=csNumber,csConstant,csCharacter,csParens,csOpSymbols,csString,csBracketed display
|
|
145 syn match csInterpolationFormat +:[^}]\+}+ contained contains=csInterpolationFormatDel display
|
|
146 syn match csInterpolationAlignDel +,+ contained display
|
|
147 syn match csInterpolationFormatDel +:+ contained display
|
|
148
|
|
149 syn region csVerbatimString matchgroup=csQuote start=+@"+ end=+"+ skip=+""+ extend contains=csVerbatimQuote,@Spell
|
|
150 syn match csVerbatimQuote +""+ contained
|
|
151 syn match csQuoteError +@$"+he=s+2,me=s+2
|
|
152
|
|
153 syn region csInterVerbString matchgroup=csQuote start=+\$@"+ end=+"+ skip=+""+ extend contains=csInterpolation,csEscapedInterpolation,csSpecialChar,csSpecialError,csUnicodeNumber,csVerbatimQuote,@Spell
|
|
154
|
|
155 syn region csBracketed matchgroup=csParens start=+(+ end=+)+ contained transparent contains=@csAll,csBracketed
|
|
156
|
17667
|
157 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
|
158
|
|
159 " The default highlighting.
|
14372
|
160 hi def link csType Type
|
|
161 hi def link csClassType Type
|
|
162 hi def link csIsType Type
|
15131
|
163 hi def link csStorage Structure
|
|
164 hi def link csClass Structure
|
14372
|
165 hi def link csRepeat Repeat
|
|
166 hi def link csConditional Conditional
|
|
167 hi def link csLabel Label
|
|
168 hi def link csModifier StorageClass
|
|
169 hi def link csConstant Constant
|
|
170 hi def link csException Exception
|
17667
|
171 hi def link csTypeOf Keyword
|
15131
|
172 hi def link csTypeOfStatement Typedef
|
14372
|
173 hi def link csUnspecifiedStatement Statement
|
|
174 hi def link csUnsupportedStatement Statement
|
|
175 hi def link csUnspecifiedKeyword Keyword
|
|
176 hi def link csNew Statement
|
|
177 hi def link csLinq Statement
|
|
178 hi def link csIsAs Keyword
|
|
179 hi def link csAsync Keyword
|
|
180 hi def link csContextualStatement Statement
|
|
181 hi def link csOperatorError Error
|
|
182
|
|
183 hi def link csTodo Todo
|
|
184 hi def link csComment Comment
|
7
|
185
|
14372
|
186 hi def link csOpSymbols Operator
|
15131
|
187 hi def link csLogicSymbols Operator
|
7
|
188
|
14372
|
189 hi def link csSpecialError Error
|
|
190 hi def link csSpecialCharError Error
|
|
191 hi def link csString String
|
|
192 hi def link csQuote String
|
|
193 hi def link csQuoteError Error
|
|
194 hi def link csInterpolatedString String
|
|
195 hi def link csVerbatimString String
|
|
196 hi def link csInterVerbString String
|
|
197 hi def link csVerbatimQuote SpecialChar
|
|
198 hi def link csPreCondit PreCondit
|
|
199 hi def link csCharacter Character
|
|
200 hi def link csSpecialChar SpecialChar
|
|
201 hi def link csNumber Number
|
|
202 hi def link csUnicodeNumber SpecialChar
|
|
203 hi def link csUnicodeSpecifier SpecialChar
|
|
204 hi def link csInterpolationDelimiter Delimiter
|
|
205 hi def link csInterpolationAlignDel csInterpolationDelimiter
|
|
206 hi def link csInterpolationFormat csInterpolationDelimiter
|
|
207 hi def link csInterpolationFormatDel csInterpolationDelimiter
|
7
|
208
|
17667
|
209 hi def link csGenericBraces csBraces
|
|
210
|
7
|
211 " xml markup
|
14372
|
212 hi def link csXmlCommentLeader Comment
|
|
213 hi def link csXmlComment Comment
|
|
214 hi def link csXmlTag Statement
|
7
|
215
|
15131
|
216 let b:current_syntax = 'cs'
|
7
|
217
|
15131
|
218 let &cpoptions = s:save_cpo
|
|
219 unlet s:save_cpo
|
7
|
220
|
14372
|
221 " vim: vts=16,28
|