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-11-26 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:save_cpo = &cpoptions 19set cpoptions&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 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" Operators 48syn keyword csTypeOf typeof contained 49syn region csTypeOfStatement start="typeof(" end=")" contains=csType, csTypeOf 50 51" Punctuation 52syn match csBraces "[{}\[\]]" display 53syn match csParens "[()]" display 54syn match csOpSymbols "[+\-=]\{1,2}" display 55syn match csOpSymbols "[><]\{2}" display 56syn match csOpSymbols "\s\zs[><]\ze\_s" display 57syn match csOpSymbols "[!><+\-*/]=" display 58syn match csOpSymbols "[!*/^]" display 59syn match csOpSymbols "=>" display 60syn match csEndColon ";" display 61syn match csLogicSymbols "&&" display 62syn match csLogicSymbols "||" display 63syn match csLogicSymbols "?" display 64syn match csLogicSymbols ":" display 65 66" Comments 67" 68" PROVIDES: @csCommentHook 69syn keyword csTodo contained TODO FIXME XXX NOTE HACK TBD 70syn region csComment start="/\*" end="\*/" contains=@csCommentHook,csTodo,@Spell 71syn match csComment "//.*$" contains=@csCommentHook,csTodo,@Spell 72 73" xml markup inside '///' comments 74syn cluster xmlRegionHook add=csXmlCommentLeader 75syn cluster xmlCdataHook add=csXmlCommentLeader 76syn cluster xmlStartTagHook add=csXmlCommentLeader 77syn keyword csXmlTag contained Libraries Packages Types Excluded ExcludedTypeName ExcludedLibraryName 78syn keyword csXmlTag contained ExcludedBucketName TypeExcluded Type TypeKind TypeSignature AssemblyInfo 79syn keyword csXmlTag contained AssemblyName AssemblyPublicKey AssemblyVersion AssemblyCulture Base 80syn keyword csXmlTag contained BaseTypeName Interfaces Interface InterfaceName Attributes Attribute 81syn keyword csXmlTag contained AttributeName Members Member MemberSignature MemberType MemberValue 82syn keyword csXmlTag contained ReturnValue ReturnType Parameters Parameter MemberOfPackage 83syn keyword csXmlTag contained ThreadingSafetyStatement Docs devdoc example overload remarks returns summary 84syn keyword csXmlTag contained threadsafe value internalonly nodoc exception param permission platnote 85syn keyword csXmlTag contained seealso b c i pre sub sup block code note paramref see subscript superscript 86syn keyword csXmlTag contained list listheader item term description altcompliant altmember 87 88syn cluster xmlTagHook add=csXmlTag 89 90syn match csXmlCommentLeader +\/\/\/+ contained 91syn match csXmlComment +\/\/\/.*$+ contains=csXmlCommentLeader,@csXml,@Spell 92syn include @csXml syntax/xml.vim 93hi def link xmlRegion Comment 94 95 96" [1] 9.5 Pre-processing directives 97syn region csPreCondit start="^\s*#\s*\(define\|undef\|if\|elif\|else\|endif\|line\|error\|warning\)" skip="\\$" end="$" contains=csComment keepend 98syn region csRegion matchgroup=csPreCondit start="^\s*#\s*region.*$" end="^\s*#\s*endregion" transparent fold contains=TOP 99syn region csSummary start="^\s*/// <summary" end="^\%\(\s*///\)\@!" transparent fold keepend 100 101 102syn region csClassType start="@\@1<!\<class\>"hs=s+6 end="[:\n{]"me=e-1 contains=csClass 103syn region csNewType start="@\@1<!\<new\>"hs=s+4 end="[;\n{(<\[]"me=e-1 contains=csNew contains=csNewType 104syn region csIsType start=" is "hs=s+4 end="[A-Za-z0-9]\+" oneline contains=csIsAs 105syn region csIsType start=" as "hs=s+4 end="[A-Za-z0-9]\+" oneline contains=csIsAs 106syn keyword csNew new contained 107syn keyword csClass class contained 108syn keyword csIsAs is as 109 110" Strings and constants 111syn match csSpecialError "\\." contained 112syn match csSpecialCharError "[^']" contained 113" [1] 9.4.4.4 Character literals 114syn match csSpecialChar +\\["\\'0abfnrtvx]+ contained display 115syn match csUnicodeNumber +\\u\x\{4}+ contained contains=csUnicodeSpecifier display 116syn match csUnicodeNumber +\\U\x\{8}+ contained contains=csUnicodeSpecifier display 117syn match csUnicodeSpecifier +\\[uU]+ contained display 118 119syn region csString matchgroup=csQuote start=+"+ end=+"+ end=+$+ extend contains=csSpecialChar,csSpecialError,csUnicodeNumber,@Spell 120syn match csCharacter "'[^']*'" contains=csSpecialChar,csSpecialCharError display 121syn match csCharacter "'\\''" contains=csSpecialChar display 122syn match csCharacter "'[^\\]'" display 123syn match csNumber "\<0[0-7]*[lL]\=\>" display 124syn match csNumber "\<0[xX]\x\+[lL]\=\>" display 125syn match csNumber "\<\d\+[lL]\=\>" display 126syn match csNumber "\<\d\+\.\d*\%\([eE][-+]\=\d\+\)\=[fFdD]\=" display 127syn match csNumber "\.\d\+\%\([eE][-+]\=\d\+\)\=[fFdD]\=" display 128syn match csNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>" display 129syn match csNumber "\<\d\+\%\([eE][-+]\=\d\+\)\=[fFdD]\>" display 130 131syn region csInterpolatedString matchgroup=csQuote start=+\$"+ end=+"+ end=+$+ extend contains=csInterpolation,csEscapedInterpolation,csSpecialChar,csSpecialError,csUnicodeNumber,@Spell 132 133syn region csInterpolation matchgroup=csInterpolationDelimiter start=+{+ end=+}+ keepend contained contains=@csAll,csBracketed,csInterpolationAlign,csInterpolationFormat 134syn match csEscapedInterpolation "{{" transparent contains=NONE display 135syn match csEscapedInterpolation "}}" transparent contains=NONE display 136syn region csInterpolationAlign matchgroup=csInterpolationAlignDel start=+,+ end=+}+ end=+:+me=e-1 contained contains=csNumber,csConstant,csCharacter,csParens,csOpSymbols,csString,csBracketed display 137syn match csInterpolationFormat +:[^}]\+}+ contained contains=csInterpolationFormatDel display 138syn match csInterpolationAlignDel +,+ contained display 139syn match csInterpolationFormatDel +:+ contained display 140 141syn region csVerbatimString matchgroup=csQuote start=+@"+ end=+"+ skip=+""+ extend contains=csVerbatimQuote,@Spell 142syn match csVerbatimQuote +""+ contained 143syn match csQuoteError +@$"+he=s+2,me=s+2 144 145syn region csInterVerbString matchgroup=csQuote start=+\$@"+ end=+"+ skip=+""+ extend contains=csInterpolation,csEscapedInterpolation,csSpecialChar,csSpecialError,csUnicodeNumber,csVerbatimQuote,@Spell 146 147syn region csBracketed matchgroup=csParens start=+(+ end=+)+ contained transparent contains=@csAll,csBracketed 148 149syn 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 150 151" The default highlighting. 152hi def link csType Type 153hi def link csClassType Type 154hi def link csIsType Type 155hi def link csStorage Structure 156hi def link csClass Structure 157hi def link csRepeat Repeat 158hi def link csConditional Conditional 159hi def link csLabel Label 160hi def link csModifier StorageClass 161hi def link csConstant Constant 162hi def link csException Exception 163hi def link csTypeOf Operator 164hi def link csTypeOfStatement Typedef 165hi def link csUnspecifiedStatement Statement 166hi def link csUnsupportedStatement Statement 167hi def link csUnspecifiedKeyword Keyword 168hi def link csNew Statement 169hi def link csLinq Statement 170hi def link csIsAs Keyword 171hi def link csAsync Keyword 172hi def link csContextualStatement Statement 173hi def link csOperatorError Error 174 175hi def link csTodo Todo 176hi def link csComment Comment 177 178hi def link csOpSymbols Operator 179hi def link csLogicSymbols Operator 180 181hi def link csSpecialError Error 182hi def link csSpecialCharError Error 183hi def link csString String 184hi def link csQuote String 185hi def link csQuoteError Error 186hi def link csInterpolatedString String 187hi def link csVerbatimString String 188hi def link csInterVerbString String 189hi def link csVerbatimQuote SpecialChar 190hi def link csPreCondit PreCondit 191hi def link csCharacter Character 192hi def link csSpecialChar SpecialChar 193hi def link csNumber Number 194hi def link csUnicodeNumber SpecialChar 195hi def link csUnicodeSpecifier SpecialChar 196hi def link csInterpolationDelimiter Delimiter 197hi def link csInterpolationAlignDel csInterpolationDelimiter 198hi def link csInterpolationFormat csInterpolationDelimiter 199hi def link csInterpolationFormatDel csInterpolationDelimiter 200 201" xml markup 202hi def link csXmlCommentLeader Comment 203hi def link csXmlComment Comment 204hi def link csXmlTag Statement 205 206let b:current_syntax = 'cs' 207 208let &cpoptions = s:save_cpo 209unlet s:save_cpo 210 211" vim: vts=16,28 212