Merge branch 'MacVim'
[MacVim/KaoriYa.git] / runtime / syntax / cs.vim
blob2ba629f921b79d8271c0f83023156e92631ac3b0
1 " Vim syntax file
2 " Language:     C#
3 " Maintainer:   Anduin Withers <awithers@anduin.com>
4 " Former Maintainer:    Johannes Zellner <johannes@zellner.org>
5 " Last Change:  Fri Aug 14 13:56:37 PDT 2009
6 " Filenames:    *.cs
7 " $Id: cs.vim,v 1.4 2006/05/03 21:20:02 vimboss Exp $
9 " REFERENCES:
10 " [1] ECMA TC39: C# Language Specification (WD13Oct01.doc)
12 if exists("b:current_syntax")
13     finish
14 endif
16 let s:cs_cpo_save = &cpo
17 set cpo&vim
20 " type
21 syn keyword csType                      bool byte char decimal double float int long object sbyte short string uint ulong ushort void
22 " storage
23 syn keyword csStorage                   class delegate enum interface namespace struct
24 " repeat / condition / label
25 syn keyword csRepeat                    break continue do for foreach goto return while
26 syn keyword csConditional               else if switch
27 syn keyword csLabel                     case default
28 " there's no :: operator in C#
29 syn match csOperatorError               display +::+
30 " user labels (see [1] 8.6 Statements)
31 syn match   csLabel                     display +^\s*\I\i*\s*:\([^:]\)\@=+
32 " modifier
33 syn keyword csModifier                  abstract const extern internal override private protected public readonly sealed static virtual volatile
34 " constant
35 syn keyword csConstant                  false null true
36 " exception
37 syn keyword csException                 try catch finally throw
39 " TODO:
40 syn keyword csUnspecifiedStatement      as base checked event fixed in is lock new operator out params ref sizeof stackalloc this typeof unchecked unsafe using
41 " TODO:
42 syn keyword csUnsupportedStatement      add remove value
43 " TODO:
44 syn keyword csUnspecifiedKeyword        explicit implicit
47 " Contextual Keywords
48 syn match csContextualStatement /\<yield[[:space:]\n]\+\(return\|break\)/me=s+5
49 syn match csContextualStatement /\<partial[[:space:]\n]\+\(class\|struct\|interface\)/me=s+7
50 syn match csContextualStatement /\<\(get\|set\)[[:space:]\n]*{/me=s+3
51 syn match csContextualStatement /\<where\>[^:]\+:/me=s+5
53 " Comments
55 " PROVIDES: @csCommentHook
57 " TODO: include strings ?
59 syn keyword csTodo              contained TODO FIXME XXX NOTE
60 syn region  csComment           start="/\*"  end="\*/" contains=@csCommentHook,csTodo,@Spell
61 syn match   csComment           "//.*$" contains=@csCommentHook,csTodo,@Spell
63 " xml markup inside '///' comments
64 syn cluster xmlRegionHook       add=csXmlCommentLeader
65 syn cluster xmlCdataHook        add=csXmlCommentLeader
66 syn cluster xmlStartTagHook     add=csXmlCommentLeader
67 syn keyword csXmlTag            contained Libraries Packages Types Excluded ExcludedTypeName ExcludedLibraryName
68 syn keyword csXmlTag            contained ExcludedBucketName TypeExcluded Type TypeKind TypeSignature AssemblyInfo
69 syn keyword csXmlTag            contained AssemblyName AssemblyPublicKey AssemblyVersion AssemblyCulture Base
70 syn keyword csXmlTag            contained BaseTypeName Interfaces Interface InterfaceName Attributes Attribute
71 syn keyword csXmlTag            contained AttributeName Members Member MemberSignature MemberType MemberValue
72 syn keyword csXmlTag            contained ReturnValue ReturnType Parameters Parameter MemberOfPackage
73 syn keyword csXmlTag            contained ThreadingSafetyStatement Docs devdoc example overload remarks returns summary
74 syn keyword csXmlTag            contained threadsafe value internalonly nodoc exception param permission platnote
75 syn keyword csXmlTag            contained seealso b c i pre sub sup block code note paramref see subscript superscript
76 syn keyword csXmlTag            contained list listheader item term description altcompliant altmember
78 syn cluster xmlTagHook add=csXmlTag
80 syn match   csXmlCommentLeader  +\/\/\/+    contained
81 syn match   csXmlComment        +\/\/\/.*$+ contains=csXmlCommentLeader,@csXml,@Spell
82 syntax include @csXml syntax/xml.vim
83 hi def link xmlRegion Comment
86 " [1] 9.5 Pre-processing directives
87 syn region      csPreCondit
88     \ start="^\s*#\s*\(define\|undef\|if\|elif\|else\|endif\|line\|error\|warning\)"
89     \ skip="\\$" end="$" contains=csComment keepend
90 syn region      csRegion matchgroup=csPreCondit start="^\s*#\s*region.*$"
91     \ end="^\s*#\s*endregion" transparent fold contains=TOP
95 " Strings and constants
96 syn match   csSpecialError      contained "\\."
97 syn match   csSpecialCharError  contained "[^']"
98 " [1] 9.4.4.4 Character literals
99 syn match   csSpecialChar       contained +\\["\\'0abfnrtvx]+
100 " unicode characters
101 syn match   csUnicodeNumber     +\\\(u\x\{4}\|U\x\{8}\)+ contained contains=csUnicodeSpecifier
102 syn match   csUnicodeSpecifier  +\\[uU]+ contained
103 syn region  csVerbatimString    start=+@"+ end=+"+ skip=+""+ contains=csVerbatimSpec,@Spell
104 syn match   csVerbatimSpec      +@"+he=s+1 contained
105 syn region  csString            start=+"+  end=+"+ end=+$+ contains=csSpecialChar,csSpecialError,csUnicodeNumber,@Spell
106 syn match   csCharacter         "'[^']*'" contains=csSpecialChar,csSpecialCharError
107 syn match   csCharacter         "'\\''" contains=csSpecialChar
108 syn match   csCharacter         "'[^\\]'"
109 syn match   csNumber            "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
110 syn match   csNumber            "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
111 syn match   csNumber            "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
112 syn match   csNumber            "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
114 " The default highlighting.
115 hi def link csType                      Type
116 hi def link csStorage                   StorageClass
117 hi def link csRepeat                    Repeat
118 hi def link csConditional               Conditional
119 hi def link csLabel                     Label
120 hi def link csModifier                  StorageClass
121 hi def link csConstant                  Constant
122 hi def link csException                 Exception
123 hi def link csUnspecifiedStatement      Statement
124 hi def link csUnsupportedStatement      Statement
125 hi def link csUnspecifiedKeyword        Keyword
126 hi def link csContextualStatement       Statement
127 hi def link csOperatorError             Error
129 hi def link csTodo                      Todo
130 hi def link csComment                   Comment
132 hi def link csSpecialError              Error
133 hi def link csSpecialCharError          Error
134 hi def link csString                    String
135 hi def link csVerbatimString            String
136 hi def link csVerbatimSpec              SpecialChar
137 hi def link csPreCondit                 PreCondit
138 hi def link csCharacter                 Character
139 hi def link csSpecialChar               SpecialChar
140 hi def link csNumber                    Number
141 hi def link csUnicodeNumber             SpecialChar
142 hi def link csUnicodeSpecifier          SpecialChar
144 " xml markup
145 hi def link csXmlCommentLeader          Comment
146 hi def link csXmlComment                Comment
147 hi def link csXmlTag                    Statement
149 let b:current_syntax = "cs"
151 let &cpo = s:cs_cpo_save
152 unlet s:cs_cpo_save
154 " vim: ts=8