codekingpro/portable-devtools
114k
1" This source file is part of the Swift.org open source project2"3" Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors4" Licensed under Apache License v2.0 with Runtime Library Exception5"6" See https://swift.org/LICENSE.txt for license information7" See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors8"9" Vim syntax file10" Language: swift11" Maintainer: Joe Groff <jgroff@apple.com>12" Last Change: 2018 Jan 2113"14" Vim maintainer: Emir SARI <bitigchi@me.com>15 16if exists("b:current_syntax")17 finish18endif19 20let s:keepcpo = &cpo21set cpo&vim22 23syn keyword swiftKeyword24 \ break25 \ case26 \ catch27 \ continue28 \ default29 \ defer30 \ do31 \ else32 \ fallthrough33 \ for34 \ guard35 \ if36 \ in37 \ repeat38 \ return39 \ switch40 \ throw41 \ try42 \ where43 \ while44syn match swiftMultiwordKeyword45 \ "indirect case"46 47syn keyword swiftCoreTypes48 \ Any49 \ AnyObject50 51syn keyword swiftImport skipwhite skipempty nextgroup=swiftImportModule52 \ import53 54syn keyword swiftDefinitionModifier55 \ convenience56 \ dynamic57 \ fileprivate58 \ final59 \ internal60 \ lazy61 \ nonmutating62 \ open63 \ override64 \ prefix65 \ private66 \ public67 \ required68 \ rethrows69 \ static70 \ throws71 \ weak72 73syn keyword swiftInOutKeyword skipwhite skipempty nextgroup=swiftTypeName74 \ inout75 76syn keyword swiftIdentifierKeyword77 \ Self78 \ metatype79 \ self80 \ super81 82syn keyword swiftFuncKeywordGeneral skipwhite skipempty nextgroup=swiftTypeParameters83 \ init84 85syn keyword swiftFuncKeyword86 \ deinit87 \ subscript88 89syn keyword swiftScope90 \ autoreleasepool91 92syn keyword swiftMutating skipwhite skipempty nextgroup=swiftFuncDefinition93 \ mutating94syn keyword swiftFuncDefinition skipwhite skipempty nextgroup=swiftTypeName,swiftOperator95 \ func96 97syn keyword swiftTypeDefinition skipwhite skipempty nextgroup=swiftTypeName98 \ class99 \ enum100 \ extension101 \ operator102 \ precedencegroup103 \ protocol104 \ struct105 106syn keyword swiftTypeAliasDefinition skipwhite skipempty nextgroup=swiftTypeAliasName107 \ associatedtype108 \ typealias109 110syn match swiftMultiwordTypeDefinition skipwhite skipempty nextgroup=swiftTypeName111 \ "indirect enum"112 113syn keyword swiftVarDefinition skipwhite skipempty nextgroup=swiftVarName114 \ let115 \ var116 117syn keyword swiftLabel118 \ get119 \ set120 \ didSet121 \ willSet122 123syn keyword swiftBoolean124 \ false125 \ true126 127syn keyword swiftNil128 \ nil129 130syn match swiftImportModule contained nextgroup=swiftImportComponent131 \ /\<[A-Za-z_][A-Za-z_0-9]*\>/132syn match swiftImportComponent contained nextgroup=swiftImportComponent133 \ /\.\<[A-Za-z_][A-Za-z_0-9]*\>/134 135syn match swiftTypeAliasName contained skipwhite skipempty nextgroup=swiftTypeAliasValue136 \ /\<[A-Za-z_][A-Za-z_0-9]*\>/137syn match swiftTypeName contained skipwhite skipempty nextgroup=swiftTypeParameters138 \ /\<[A-Za-z_][A-Za-z_0-9\.]*\>/139syn match swiftVarName contained skipwhite skipempty nextgroup=swiftTypeDeclaration140 \ /\<[A-Za-z_][A-Za-z_0-9]*\>/141syn match swiftImplicitVarName142 \ /\$\<[A-Za-z_0-9]\+\>/143 144" TypeName[Optionality]?145syn match swiftType contained skipwhite skipempty nextgroup=swiftTypeParameters146 \ /\<[A-Za-z_][A-Za-z_0-9\.]*\>[!?]\?/147" [Type:Type] (dictionary) or [Type] (array)148syn region swiftType contained contains=swiftTypePair,swiftType149 \ matchgroup=Delimiter start=/\[/ end=/\]/150syn match swiftTypePair contained skipwhite skipempty nextgroup=swiftTypeParameters,swiftTypeDeclaration151 \ /\<[A-Za-z_][A-Za-z_0-9\.]*\>[!?]\?/152" (Type[, Type]) (tuple)153" FIXME: we should be able to use skip="," and drop swiftParamDelim154syn region swiftType contained contains=swiftType,swiftParamDelim155 \ matchgroup=Delimiter start="[^@]\?(" end=")" matchgroup=NONE skip=","156syn match swiftParamDelim contained157 \ /,/158" <Generic Clause> (generics)159syn region swiftTypeParameters contained contains=swiftVarName,swiftConstraint160 \ matchgroup=Delimiter start="<" end=">" matchgroup=NONE skip=","161syn keyword swiftConstraint contained162 \ where163 164syn match swiftTypeAliasValue skipwhite skipempty nextgroup=swiftType165 \ /=/166syn match swiftTypeDeclaration skipwhite skipempty nextgroup=swiftType,swiftInOutKeyword167 \ /:/168syn match swiftTypeDeclaration skipwhite skipempty nextgroup=swiftType169 \ /->/170 171syn match swiftKeyword172 \ /\<case\>/173syn region swiftCaseLabelRegion174 \ matchgroup=swiftKeyword start=/\<case\>/ matchgroup=Delimiter end=/:/ oneline contains=TOP175syn region swiftDefaultLabelRegion176 \ matchgroup=swiftKeyword start=/\<default\>/ matchgroup=Delimiter end=/:/ oneline177 178syn region swiftParenthesisRegion contains=TOP179 \ matchgroup=NONE start=/(/ end=/)/180 181syn region swiftString contains=swiftInterpolationRegion182 \ start=/"/ skip=/\\\\\|\\"/ end=/"/183syn region swiftInterpolationRegion contained contains=TOP184 \ matchgroup=swiftInterpolation start=/\\(/ end=/)/185syn region swiftComment contains=swiftComment,swiftLineComment,swiftTodo186 \ start="/\*" end="\*/"187syn region swiftLineComment contains=swiftComment,swiftTodo188 \ start="//" end="$"189 190syn match swiftDecimal191 \ /[+\-]\?\<\([0-9][0-9_]*\)\([.][0-9_]*\)\?\([eE][+\-]\?[0-9][0-9_]*\)\?\>/192syn match swiftHex193 \ /[+\-]\?\<0x[0-9A-Fa-f][0-9A-Fa-f_]*\(\([.][0-9A-Fa-f_]*\)\?[pP][+\-]\?[0-9][0-9_]*\)\?\>/194syn match swiftOct195 \ /[+\-]\?\<0o[0-7][0-7_]*\>/196syn match swiftBin197 \ /[+\-]\?\<0b[01][01_]*\>/198 199syn match swiftOperator skipwhite skipempty nextgroup=swiftTypeParameters200 \ "\.\@<!\.\.\.\@!\|[/=\-+*%<>!&|^~]\@<!\(/[/*]\@![/=\-+*%<>!&|^~]*\|*/\@![/=\-+*%<>!&|^~]*\|->\@![/=\-+*%<>!&|^~]*\|[=+%<>!&|^~][/=\-+*%<>!&|^~]*\)"201syn match swiftOperator skipwhite skipempty nextgroup=swiftTypeParameters202 \ "\.\.[<.]"203 204syn match swiftChar205 \ /'\([^'\\]\|\\\(["'tnr0\\]\|x[0-9a-fA-F]\{2}\|u[0-9a-fA-F]\{4}\|U[0-9a-fA-F]\{8}\)\)'/206 207syn match swiftTupleIndexNumber contains=swiftDecimal208 \ /\.[0-9]\+/209syn match swiftDecimal contained210 \ /[0-9]\+/211 212syn match swiftPreproc213 \ /#\(\<column\>\|\<dsohandle\>\|\<file\>\|\<line\>\|\<function\>\)/214syn match swiftPreproc215 \ /^\s*#\(\<if\>\|\<else\>\|\<elseif\>\|\<endif\>\|\<error\>\|\<warning\>\)/216syn region swiftPreprocFalse217 \ start="^\s*#\<if\>\s\+\<false\>" end="^\s*#\(\<else\>\|\<elseif\>\|\<endif\>\)"218 219syn match swiftAttribute220 \ /@\<\w\+\>/ skipwhite skipempty nextgroup=swiftType,swiftTypeDefinition221 222syn keyword swiftTodo MARK TODO FIXME contained223 224syn match swiftCastOp skipwhite skipempty nextgroup=swiftType,swiftCoreTypes225 \ "\<is\>"226syn match swiftCastOp skipwhite skipempty nextgroup=swiftType,swiftCoreTypes227 \ "\<as\>[!?]\?"228 229syn match swiftNilOps230 \ "??"231 232syn region swiftReservedIdentifier oneline233 \ start=/`/ end=/`/234 235hi def link swiftImport Include236hi def link swiftImportModule Title237hi def link swiftImportComponent Identifier238hi def link swiftKeyword Statement239hi def link swiftCoreTypes Type240hi def link swiftMultiwordKeyword Statement241hi def link swiftTypeDefinition Define242hi def link swiftMultiwordTypeDefinition Define243hi def link swiftType Type244hi def link swiftTypePair Type245hi def link swiftTypeAliasName Identifier246hi def link swiftTypeName Function247hi def link swiftConstraint Special248hi def link swiftFuncDefinition Define249hi def link swiftDefinitionModifier Operator250hi def link swiftInOutKeyword Define251hi def link swiftFuncKeyword Function252hi def link swiftFuncKeywordGeneral Function253hi def link swiftTypeAliasDefinition Define254hi def link swiftVarDefinition Define255hi def link swiftVarName Identifier256hi def link swiftImplicitVarName Identifier257hi def link swiftIdentifierKeyword Identifier258hi def link swiftTypeAliasValue Delimiter259hi def link swiftTypeDeclaration Delimiter260hi def link swiftTypeParameters Delimiter261hi def link swiftBoolean Boolean262hi def link swiftString String263hi def link swiftInterpolation Special264hi def link swiftComment Comment265hi def link swiftLineComment Comment266hi def link swiftDecimal Number267hi def link swiftHex Number268hi def link swiftOct Number269hi def link swiftBin Number270hi def link swiftOperator Function271hi def link swiftChar Character272hi def link swiftLabel Operator273hi def link swiftMutating Statement274hi def link swiftPreproc PreCondit275hi def link swiftPreprocFalse Comment276hi def link swiftAttribute Type277hi def link swiftTodo Todo278hi def link swiftNil Constant279hi def link swiftCastOp Operator280hi def link swiftNilOps Operator281hi def link swiftScope PreProc282 283let b:current_syntax = "swift"284 285let &cpo = s:keepcpo286unlet s:keepcpo287 