7
|
1 " Vim syntax file
|
13857
|
2 " Language: C#
|
|
3 " Maintainer: Nick Jensen <nickspoon@gmail.com>
|
|
4 " Former Maintainer: Anduin Withers <awithers@anduin.com>
|
859
|
5 " Former Maintainer: Johannes Zellner <johannes@zellner.org>
|
13857
|
6 " Last Change: 2018-05-02
|
|
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
|
|
14 if exists("b:current_syntax")
|
|
15 finish
|
|
16 endif
|
|
17
|
|
18 let s:cs_cpo_save = &cpo
|
|
19 set cpo&vim
|
|
20
|
|
21
|
13857
|
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
|
7
|
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 " there's no :: operator in C#
|
|
28 syn match csOperatorError display +::+
|
|
29 " user labels (see [1] 8.6 Statements)
|
|
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
|
13857
|
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
|
13857
|
37 syn keyword csUnspecifiedStatement as base checked event fixed get in is lock nameof operator out params ref set sizeof stackalloc this typeof unchecked unsafe using
|
859
|
38 syn keyword csUnsupportedStatement add remove value
|
7
|
39 syn keyword csUnspecifiedKeyword explicit implicit
|
|
40
|
859
|
41 " Contextual Keywords
|
|
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
|
7
|
46
|
|
47 " Comments
|
|
48 "
|
|
49 " PROVIDES: @csCommentHook
|
|
50 "
|
|
51 " TODO: include strings ?
|
|
52 "
|
13857
|
53 syn keyword csTodo contained TODO FIXME XXX NOTE HACK
|
843
|
54 syn region csComment start="/\*" end="\*/" contains=@csCommentHook,csTodo,@Spell
|
|
55 syn match csComment "//.*$" contains=@csCommentHook,csTodo,@Spell
|
7
|
56
|
|
57 " xml markup inside '///' comments
|
|
58 syn cluster xmlRegionHook add=csXmlCommentLeader
|
|
59 syn cluster xmlCdataHook add=csXmlCommentLeader
|
|
60 syn cluster xmlStartTagHook add=csXmlCommentLeader
|
|
61 syn keyword csXmlTag contained Libraries Packages Types Excluded ExcludedTypeName ExcludedLibraryName
|
|
62 syn keyword csXmlTag contained ExcludedBucketName TypeExcluded Type TypeKind TypeSignature AssemblyInfo
|
|
63 syn keyword csXmlTag contained AssemblyName AssemblyPublicKey AssemblyVersion AssemblyCulture Base
|
|
64 syn keyword csXmlTag contained BaseTypeName Interfaces Interface InterfaceName Attributes Attribute
|
|
65 syn keyword csXmlTag contained AttributeName Members Member MemberSignature MemberType MemberValue
|
|
66 syn keyword csXmlTag contained ReturnValue ReturnType Parameters Parameter MemberOfPackage
|
|
67 syn keyword csXmlTag contained ThreadingSafetyStatement Docs devdoc example overload remarks returns summary
|
|
68 syn keyword csXmlTag contained threadsafe value internalonly nodoc exception param permission platnote
|
|
69 syn keyword csXmlTag contained seealso b c i pre sub sup block code note paramref see subscript superscript
|
|
70 syn keyword csXmlTag contained list listheader item term description altcompliant altmember
|
|
71
|
|
72 syn cluster xmlTagHook add=csXmlTag
|
|
73
|
|
74 syn match csXmlCommentLeader +\/\/\/+ contained
|
2034
|
75 syn match csXmlComment +\/\/\/.*$+ contains=csXmlCommentLeader,@csXml,@Spell
|
|
76 syntax include @csXml syntax/xml.vim
|
7
|
77 hi def link xmlRegion Comment
|
|
78
|
|
79
|
|
80 " [1] 9.5 Pre-processing directives
|
|
81 syn region csPreCondit
|
859
|
82 \ start="^\s*#\s*\(define\|undef\|if\|elif\|else\|endif\|line\|error\|warning\)"
|
7
|
83 \ skip="\\$" end="$" contains=csComment keepend
|
859
|
84 syn region csRegion matchgroup=csPreCondit start="^\s*#\s*region.*$"
|
|
85 \ end="^\s*#\s*endregion" transparent fold contains=TOP
|
13857
|
86 syn region csSummary start="^\s*/// <summary" end="^\(\s*///\)\@!" transparent fold keepend
|
7
|
87
|
|
88
|
13857
|
89 syn region csClassType start="\(@\)\@<!class\>"hs=s+6 end="[:\n{]"he=e-1 contains=csClass
|
|
90 syn region csNewType start="\(@\)\@<!new\>"hs=s+4 end="[\(\<{\[]"he=e-1 contains=csNew contains=csNewType
|
|
91 syn region csIsType start="\v (is|as) "hs=s+4 end="\v[A-Za-z0-9]+" oneline contains=csIsAs
|
|
92 syn keyword csNew new contained
|
|
93 syn keyword csClass class contained
|
|
94 syn keyword csIsAs is as
|
7
|
95
|
|
96 " Strings and constants
|
|
97 syn match csSpecialError contained "\\."
|
|
98 syn match csSpecialCharError contained "[^']"
|
|
99 " [1] 9.4.4.4 Character literals
|
|
100 syn match csSpecialChar contained +\\["\\'0abfnrtvx]+
|
|
101 " unicode characters
|
|
102 syn match csUnicodeNumber +\\\(u\x\{4}\|U\x\{8}\)+ contained contains=csUnicodeSpecifier
|
|
103 syn match csUnicodeSpecifier +\\[uU]+ contained
|
2034
|
104 syn region csVerbatimString start=+@"+ end=+"+ skip=+""+ contains=csVerbatimSpec,@Spell
|
7
|
105 syn match csVerbatimSpec +@"+he=s+1 contained
|
843
|
106 syn region csString start=+"+ end=+"+ end=+$+ contains=csSpecialChar,csSpecialError,csUnicodeNumber,@Spell
|
7
|
107 syn match csCharacter "'[^']*'" contains=csSpecialChar,csSpecialCharError
|
|
108 syn match csCharacter "'\\''" contains=csSpecialChar
|
|
109 syn match csCharacter "'[^\\]'"
|
|
110 syn match csNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
|
|
111 syn match csNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
|
|
112 syn match csNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
|
|
113 syn match csNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
|
|
114
|
|
115 " The default highlighting.
|
|
116 hi def link csType Type
|
13857
|
117 hi def link csNewType Type
|
|
118 hi def link csClassType Type
|
|
119 hi def link csIsType Type
|
7
|
120 hi def link csStorage StorageClass
|
13857
|
121 hi def link csClass StorageClass
|
7
|
122 hi def link csRepeat Repeat
|
|
123 hi def link csConditional Conditional
|
|
124 hi def link csLabel Label
|
|
125 hi def link csModifier StorageClass
|
|
126 hi def link csConstant Constant
|
|
127 hi def link csException Exception
|
|
128 hi def link csUnspecifiedStatement Statement
|
|
129 hi def link csUnsupportedStatement Statement
|
|
130 hi def link csUnspecifiedKeyword Keyword
|
13857
|
131 hi def link csNew Statement
|
|
132 hi def link csLinq Statement
|
|
133 hi def link csIsAs Keyword
|
|
134 hi def link csAsync Keyword
|
859
|
135 hi def link csContextualStatement Statement
|
7
|
136 hi def link csOperatorError Error
|
13857
|
137 hi def link csInterfaceDeclaration Include
|
7
|
138
|
|
139 hi def link csTodo Todo
|
|
140 hi def link csComment Comment
|
|
141
|
|
142 hi def link csSpecialError Error
|
|
143 hi def link csSpecialCharError Error
|
|
144 hi def link csString String
|
|
145 hi def link csVerbatimString String
|
|
146 hi def link csVerbatimSpec SpecialChar
|
|
147 hi def link csPreCondit PreCondit
|
|
148 hi def link csCharacter Character
|
|
149 hi def link csSpecialChar SpecialChar
|
|
150 hi def link csNumber Number
|
|
151 hi def link csUnicodeNumber SpecialChar
|
|
152 hi def link csUnicodeSpecifier SpecialChar
|
|
153
|
|
154 " xml markup
|
|
155 hi def link csXmlCommentLeader Comment
|
|
156 hi def link csXmlComment Comment
|
|
157 hi def link csXmlTag Statement
|
|
158
|
|
159 let b:current_syntax = "cs"
|
|
160
|
|
161 let &cpo = s:cs_cpo_save
|
|
162 unlet s:cs_cpo_save
|
|
163
|
|
164 " vim: ts=8
|