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