@@ -7,53 +7,46 @@ if exists("b:current_syntax")
77 finish
88endif
99
10- syn keyword swiftImport import skipwhite nextgroup =swiftImportModule
11-
12- syn match swiftImportModule / \< [A-Za-z_][A-Za-z_0-9]*\> / contained nextgroup =swiftImportComponent
13- syn match swiftImportComponent / \.\< [A-Za-z_][A-Za-z_0-9]*\> / contained nextgroup =swiftImportComponent
14-
1510syn keyword swiftKeyword
1611 \ associatedtype
1712 \ break
1813 \ case
1914 \ catch
2015 \ continue
21- \ convenience
2216 \ default
2317 \ defer
2418 \ do
2519 \ else
26- \ extension
27- \ final
2820 \ for
2921 \ guard
3022 \ if
3123 \ in
32- \ internal
3324 \ let
34- \ mutating
35- \ nonmutating
36- \ override
37- \ private
38- \ protocol
39- \ public
4025 \ repeat
41- \ required
4226 \ return
43- \ static
4427 \ switch
4528 \ throw
4629 \ try
4730 \ typealias
4831 \ var
4932 \ where
5033 \ while
34+ syn match swiftMultiwordKeyword
35+ \ " indirect case"
36+
37+ syn keyword swiftImport skipwhite nextgroup =swiftImportModule
38+ \ import
5139
5240syn keyword swiftDefinitionModifier
41+ \ convenience
5342 \ dynamic
43+ \ final
5444 \ internal
45+ \ nonmutating
46+ \ override
5547 \ private
5648 \ public
49+ \ required
5750 \ rethrows
5851 \ static
5952 \ throws
@@ -75,6 +68,11 @@ syn keyword swiftFuncKeyword
7568syn keyword swiftScope
7669 \ autoreleasepool
7770
71+ syn keyword swiftMutating skipwhite nextgroup =swiftFuncDefinition
72+ \ mutating
73+ syn keyword swiftFuncDefinition skipwhite nextgroup =swiftTypeName,swiftOperator
74+ \ func
75+
7876syn keyword swiftTypeDefinition skipwhite nextgroup =swiftTypeName
7977 \ class
8078 \ enum
@@ -83,47 +81,57 @@ syn keyword swiftTypeDefinition skipwhite nextgroup=swiftTypeName
8381 \ struct
8482 \ typealias
8583
86- syn keyword swiftNew skipwhite nextgroup =swiftTypeName
87- \ new
84+ syn keyword swiftVarDefinition skipwhite nextgroup =swiftVarName
85+ \ let
86+ \ var
87+
88+ syn keyword swiftLabel
89+ \ get
90+ \ set
91+
92+ syn keyword swiftBoolean
93+ \ false
94+ \ true
95+
96+ syn keyword swiftNil
97+ \ nil
98+
99+ syn match swiftImportModule contained nextgroup =swiftImportComponent
100+ \ /\<[A-Za-z_][A-Za-z_0-9]*\>/
101+ syn match swiftImportComponent contained nextgroup =swiftImportComponent
102+ \ /\.\<[A-Za-z_][A-Za-z_0-9]*\>/
88103
89104syn match swiftTypeName contained nextgroup =swiftTypeParameters
90105 \ /\<[A-Za-z_][A-Za-z_0-9\.]*\>/
106+ syn match swiftVarName contained skipwhite nextgroup =swiftTypeDeclaration
107+ \ /\<[A-Za-z_][A-Za-z_0-9]*\>/
108+ syn match swiftImplicitVarName
109+ \ /\$\<[A-Za-z_0-9]\+\>/
91110
92111" TypeName[Optionality]?
93112syn match swiftType contained nextgroup =swiftTypeParameters
94113 \ /\<[A-Za-z_][A-Za-z_0-9\.]*\>[!?]\?/
95114" [Type:Type] (dictionary) or [Type] (array)
96115syn region swiftType contained contains =swiftTypePair,swiftType
97- \ start = /\[/ end = /\]/
116+ \ matchgroup = Delimiter start = /\[/ end = /\]/
98117syn match swiftTypePair contained nextgroup =swiftTypeParameters,swiftTypeDeclaration
99118 \ /\<[A-Za-z_][A-Za-z_0-9\.]*\>[!?]\?/
100119" (Type[, Type]) (tuple)
120+ " FIXME: we should be able to use skip="," and drop swiftParamDelim
101121syn region swiftType contained contains =swiftType,swiftParamDelim
102- \ start = " [^@](" end = " )"
122+ \ matchgroup = Delimiter start = " [^@](" end = " )" matchgroup = NONE skip = " , "
103123syn match swiftParamDelim contained
104124 \ /,/
105125" <Generic Clause> (generics)
106- syn region swiftTypeParameters contained contains =swiftArchetype,swiftConstraint
107- \ start = " <" end = " >"
108- syn match swiftArchetype contained skipwhite nextgroup =swiftTypeDeclaration
109- \ /\<[A-Za-z_][A-Za-z_0-9]*\>/
126+ syn region swiftTypeParameters contained contains =swiftVarName,swiftConstraint
127+ \ matchgroup= Delimiter start = " <" end = " >" matchgroup= NONE skip = " ,"
110128syn keyword swiftConstraint contained
111129 \ where
112130
113- syn keyword swiftMutating mutating skipwhite nextgroup =swiftFuncDefinition
114- syn keyword swiftFuncDefinition func skipwhite nextgroup =swiftFuncName,swiftOperator
115- syn match swiftFuncName / \< [A-Za-z_][A-Za-z_0-9]*\> / contained skipwhite nextgroup =swiftTypeParameters
116-
117- syn keyword swiftVarDefinition var skipwhite nextgroup =swiftVarName
118- syn keyword swiftVarDefinition let skipwhite nextgroup =swiftVarName
119- syn match swiftVarName / \< [A-Za-z_][A-Za-z_0-9]*\> / contained
120-
121- syn match swiftImplicitVarName / \$\< [A-Za-z_0-9]\+\> /
122-
123- syn match swiftTypeDeclaration / :/ skipwhite nextgroup =swiftType
124- syn match swiftTypeDeclaration / ->/ skipwhite nextgroup =swiftType
125-
126- syn keyword swiftBoolean true false
131+ syn match swiftTypeDeclaration skipwhite nextgroup =swiftType
132+ \ /:/
133+ syn match swiftTypeDeclaration skipwhite nextgroup =swiftType
134+ \ /->/
127135
128136syn region swiftString start =/ "/ skip =/ \\\\\|\\ "/ end =/ "/ contains =swiftInterpolation
129137syn region swiftInterpolation start =/ \\ (/ end =/ )/ contained
@@ -140,16 +148,15 @@ syn match swiftOperator "\.\.[<.]" skipwhite nextgroup=swiftTypeParameters
140148
141149syn match swiftChar / '\( [^'\\ ]\|\\\( ["'tnr0\\ ]\| x[0-9a-fA-F]\{ 2}\| u[0-9a-fA-F]\{ 4}\| U[0-9a-fA-F]\{ 8}\)\) '/
142150
143- syn keyword swiftLabel get set
144-
151+ syn match swiftPreproc / #\(\< file\>\|\< line\>\) /
145152syn match swiftPreproc / ^\s *#\(\< if\>\|\< else\>\|\< elseif\>\|\< endif\>\) /
146153syn region swiftPreprocFalse start =" ^\s *#\< if\>\s\+\< false\> " end =" ^\s *#\(\< else\>\|\< elseif\>\|\< endif\>\) "
147154
148155syn match swiftAttribute / @\<\w\+\> / skipwhite nextgroup =swiftType
149156
150157syn keyword swiftTodo TODO FIXME contained
151- syn keyword swiftNil nil
152158
159+ syn match swiftCastOp " \< is\> " skipwhite nextgroup =swiftType
153160syn match swiftCastOp " \< as\> [!?]\? " skipwhite nextgroup =swiftType
154161
155162syn match swiftNilOps " ??"
@@ -161,15 +168,14 @@ hi def link swiftImport Include
161168hi def link swiftImportModule Title
162169hi def link swiftImportComponent Identifier
163170hi def link swiftKeyword Statement
171+ hi def link swiftMultiwordKeyword Statement
164172hi def link swiftTypeDefinition Define
165173hi def link swiftType Type
166174hi def link swiftTypePair Type
167175hi def link swiftTypeName Function
168- hi def link swiftArchetype Identifier
169176hi def link swiftConstraint Special
170177hi def link swiftFuncDefinition Define
171178hi def link swiftDefinitionModifier Define
172- hi def link swiftFuncName Function
173179hi def link swiftFuncKeyword Function
174180hi def link swiftFuncKeywordGeneral Function
175181hi def link swiftVarDefinition Define
@@ -190,7 +196,6 @@ hi def link swiftBin Number
190196hi def link swiftOperator Function
191197hi def link swiftChar Character
192198hi def link swiftLabel Operator
193- hi def link swiftNew Operator
194199hi def link swiftMutating Statement
195200hi def link swiftPreproc PreCondit
196201hi def link swiftPreprocFalse Comment
0 commit comments