Created
July 22, 2016 12:29
-
-
Save sowderca/54d2cfdc93af0daa376618aa9afe07f7 to your computer and use it in GitHub Desktop.
c# syntax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Vim syntax file | |
" Language: csharp | |
" Author: Cameron Sowder | |
" Version: 0.0.1 | |
if !exists("main_syntax") | |
if version < 600 | |
syntax clear | |
elseif exists("b:current_syntax") | |
finish | |
endif | |
let main_syntax = "cs" | |
endif | |
" Keywords | |
syntax sync fromstart | |
" Types | Value Types | |
syntax keyword csharpValueTypes bool byte char decimal double float int long sbyte short uint ulong dynamic string object void | |
syntax keyword csharpReserved struct interface enum namespace abstract const internal override private protected public readonly sealed static virtual volatile class as delegate extern is ref params out | |
syntax keyword csharpBranch break continue yield await | |
syntax keyword csharpStatement return explicit implicit operator sizeof typeof nameof stackalloc | |
syntax keyword csharpBoolean true false | |
syntax keyword csharpNull null | |
syntax keyword csharpOperator new add remove value get global partial set where | |
syntax keyword charpExceptions try catch finally throw | |
syntax keyword csharpConditional else if switch | |
syntax keyword csharpRepeat do while for of foreach | |
syntax keyword csharpLabel case default async | |
syntax keyword csharpChecked checked unchecked fixed lock | |
syntax keyword csharpLinq from where select group into orderby join let in on equals by ascending descending | |
syntax keyword csharpIdentifier this base const var | |
syntax keyword csharpSource using | |
syn match csharpBraces "[{}\[\]]" | |
syn match csharpParens "[()]" | |
syn match csharpOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-=\|?\|=>\|??\|->\|>>=\|=<<\||=\|&\|%\|\|*=\|>>\|<<\|*\|::" | |
syn match csharpEndColons "[;,]" | |
" skip curly braces inside RegEx's and comments | |
syn region foldBraces start=/{/ skip=/\(\/\/.*\)\|\(\/.*\/\)/ end=/}/ transparent fold keepend extend | |
" Comments | |
" | |
" PROVIDES: @csCommentHook | |
" | |
" TODO: include strings ? | |
" | |
syn keyword csharpTodo contained TODO FIXME XXX NOTE | |
syn region csharpComment start="/\*" end="\*/" contains=@csCommentHook,csTodo,@Spell | |
syn match csharpComment "//.*$" contains=@csCommentHook,csTodo,@Spell | |
" xml markup inside '///' comments | |
syn cluster xmlRegionHook add=csXmlCommentLeader | |
syn cluster xmlCdataHook add=csXmlCommentLeader | |
syn cluster xmlStartTagHook add=csXmlCommentLeader | |
syn keyword csharpXmlTag contained Libraries Packages Types Excluded ExcludedTypeName ExcludedLibraryName | |
syn keyword csharpXmlTag contained ExcludedBucketName TypeExcluded Type TypeKind TypeSignature AssemblyInfo | |
syn keyword csharpXmlTag contained AssemblyName AssemblyPublicKey AssemblyVersion AssemblyCulture Base | |
syn keyword csharpXmlTag contained BaseTypeName Interfaces Interface InterfaceName Attributes Attribute | |
syn keyword csharpXmlTag contained AttributeName Members Member MemberSignature MemberType MemberValue | |
syn keyword csharpXmlTag contained ReturnValue ReturnType Parameters Parameter MemberOfPackage | |
syn keyword csharpXmlTag contained ThreadingSafetyStatement Docs devdoc example overload remarks returns summary | |
syn keyword csharpXmlTag contained threadsafe value internalonly nodoc exception param permission platnote | |
syn keyword csharpXmlTag contained seealso b c i pre sub sup block code note paramref see subscript superscript | |
syn keyword csharpXmlTag contained list listheader item term description altcompliant altmember | |
syn cluster xmlTagHook add=csXmlTag | |
syn match csharpXmlCommentLeader +\/\/\/+ contained | |
syn match csharpXmlComment +\/\/\/.*$+ contains=csXmlCommentLeader,@csXml,@Spell | |
syntax include @csXml syntax/xml.vim | |
hi def link xmlRegion Comment | |
" Strings and constants | |
syn match csharpSpecialError contained "\\." | |
syn match csharpSpecialCharError contained "[^']" | |
" [1] 9.4.4.4 Character literals | |
syn match csharpSpecialChar contained +\\["\\'0abfnrtvx]+ | |
" unicode characters | |
syn match csharpUnicodeNumber +\\\(u\x\{4}\|U\x\{8}\)+ contained contains=csUnicodeSpecifier | |
syn match csharpUnicodeSpecifier +\\[uU]+ contained | |
syn region csharpVerbatimString start=+@"+ end=+"+ skip=+""+ contains=csVerbatimSpec,@Spell | |
syn match csharpVerbatimSpec +@"+he=s+1 contained | |
syn region csharpString start=+"+ end=+"+ end=+$+ contains=csSpecialChar,csSpecialError,csUnicodeNumber,@Spell | |
syn match csharpCharacter "'[^']*'" contains=csSpecialChar,csSpecialCharError | |
syn match csharpCharacter "'\\''" contains=csSpecialChar | |
syn match csharpCharacter "'[^\\]'" | |
syn match csharpNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>" | |
syn match csharpNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\=" | |
syn match csharpNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>" | |
syn match csharpNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>" | |
syntax cluster csharpAll contains=csharpValueTypes,csharpReserved,csharpBranch,csharpStatement,csharpBoolean,csharpNull,csharpOperator,csharpExceptions,csharpConditional,csharpRepeat,csharpLabel,csharpChecked,csharpLinq,csharpIdentifier | |
if version >= 508 || !exists("did_csharp_syn_inits") | |
if version < 508 | |
let did_csharp_syn_inits = 1 | |
command -nargs=+ HiLink hi link <args> | |
else | |
command -nargs=+ HiLink hi def link <args> | |
endif | |
"typescript highlighting | |
HiLink csharpParameters Operator | |
HiLink csharpSuperBlock Operator | |
HiLink csharpEndColons Exception | |
HiLink csharpOpSymbols Operator | |
HiLink csharpLogicSymbols Boolean | |
HiLink csharpBraces Function | |
HiLink csharpParens Operator | |
HiLink csharpComment Comment | |
HiLink csharpLineComment Comment | |
HiLink csharpRefComment Include | |
HiLink csharpRefS String | |
HiLink csharpRefD String | |
HiLink csharpDocComment Comment | |
HiLink csharpCommentTodo Todo | |
HiLink csharpCvsTag Function | |
HiLink csharpDocTags Special | |
HiLink csharpDocSeeTag Function | |
HiLink csharpDocParam Function | |
HiLink csharpString String | |
HiLink csharpStringD String | |
HiLink csharpStringB String | |
HiLink csharpRegexpString String | |
HiLink csharpGlobal Constant | |
HiLink csharpCharacter Character | |
HiLink csharpPrototype Type | |
HiLink csharpConditional Conditional | |
HiLink csharpBranch Conditional | |
HiLink csharpIdentifier Identifier | |
HiLink csharpRepeat Repeat | |
HiLink csharpStatement Statement | |
HiLink csharpFuncKeyword Function | |
HiLink csharpMessage Keyword | |
HiLink csharpDeprecated Exception | |
HiLink csharpError Error | |
HiLink csharpParensError Error | |
HiLink csharpParensErrA Error | |
HiLink csharpParensErrB Error | |
HiLink csharpParensErrC Error | |
HiLink csharpReserved Keyword | |
HiLink csharpOperator Operator | |
HiLink csharpValueTypes Type | |
HiLink csharpNull Type | |
HiLink csharpNumber Number | |
HiLink csharpFloat Number | |
HiLink csharpDecorators Special | |
HiLink csharpBoolean Boolean | |
HiLink csharpLabel Label | |
HiLink csharpSpecial Special | |
HiLink csharpSource Special | |
HiLink csharpGlobalObjects Special | |
HiLink csharpExceptions Special | |
HiLink csharpNumber Number | |
delcommand HiLink | |
endif | |
let b:current_syntax = "cs" | |
if main_syntax == 'cs' | |
unlet main_syntax | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment