@@ -7,53 +7,46 @@ if exists("b:current_syntax")
7
7
finish
8
8
endif
9
9
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
-
15
10
syn keyword swiftKeyword
16
11
\ associatedtype
17
12
\ break
18
13
\ case
19
14
\ catch
20
15
\ continue
21
- \ convenience
22
16
\ default
23
17
\ defer
24
18
\ do
25
19
\ else
26
- \ extension
27
- \ final
28
20
\ for
29
21
\ guard
30
22
\ if
31
23
\ in
32
- \ internal
33
24
\ let
34
- \ mutating
35
- \ nonmutating
36
- \ override
37
- \ private
38
- \ protocol
39
- \ public
40
25
\ repeat
41
- \ required
42
26
\ return
43
- \ static
44
27
\ switch
45
28
\ throw
46
29
\ try
47
30
\ typealias
48
31
\ var
49
32
\ where
50
33
\ while
34
+ syn match swiftMultiwordKeyword
35
+ \ " indirect case"
36
+
37
+ syn keyword swiftImport skipwhite nextgroup =swiftImportModule
38
+ \ import
51
39
52
40
syn keyword swiftDefinitionModifier
41
+ \ convenience
53
42
\ dynamic
43
+ \ final
54
44
\ internal
45
+ \ nonmutating
46
+ \ override
55
47
\ private
56
48
\ public
49
+ \ required
57
50
\ rethrows
58
51
\ static
59
52
\ throws
@@ -75,6 +68,11 @@ syn keyword swiftFuncKeyword
75
68
syn keyword swiftScope
76
69
\ autoreleasepool
77
70
71
+ syn keyword swiftMutating skipwhite nextgroup =swiftFuncDefinition
72
+ \ mutating
73
+ syn keyword swiftFuncDefinition skipwhite nextgroup =swiftTypeName,swiftOperator
74
+ \ func
75
+
78
76
syn keyword swiftTypeDefinition skipwhite nextgroup =swiftTypeName
79
77
\ class
80
78
\ enum
@@ -83,47 +81,57 @@ syn keyword swiftTypeDefinition skipwhite nextgroup=swiftTypeName
83
81
\ struct
84
82
\ typealias
85
83
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]*\>/
88
103
89
104
syn match swiftTypeName contained nextgroup =swiftTypeParameters
90
105
\ /\<[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]\+\>/
91
110
92
111
" TypeName[Optionality]?
93
112
syn match swiftType contained nextgroup =swiftTypeParameters
94
113
\ /\<[A-Za-z_][A-Za-z_0-9\.]*\>[!?]\?/
95
114
" [Type:Type] (dictionary) or [Type] (array)
96
115
syn region swiftType contained contains =swiftTypePair,swiftType
97
- \ start = /\[/ end = /\]/
116
+ \ matchgroup = Delimiter start = /\[/ end = /\]/
98
117
syn match swiftTypePair contained nextgroup =swiftTypeParameters,swiftTypeDeclaration
99
118
\ /\<[A-Za-z_][A-Za-z_0-9\.]*\>[!?]\?/
100
119
" (Type[, Type]) (tuple)
120
+ " FIXME: we should be able to use skip="," and drop swiftParamDelim
101
121
syn region swiftType contained contains =swiftType,swiftParamDelim
102
- \ start = " [^@](" end = " )"
122
+ \ matchgroup = Delimiter start = " [^@](" end = " )" matchgroup = NONE skip = " , "
103
123
syn match swiftParamDelim contained
104
124
\ /,/
105
125
" <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 = " ,"
110
128
syn keyword swiftConstraint contained
111
129
\ where
112
130
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
+ \ /->/
127
135
128
136
syn region swiftString start =/ "/ skip =/ \\\\\|\\ "/ end =/ "/ contains =swiftInterpolation
129
137
syn region swiftInterpolation start =/ \\ (/ end =/ )/ contained
@@ -140,16 +148,15 @@ syn match swiftOperator "\.\.[<.]" skipwhite nextgroup=swiftTypeParameters
140
148
141
149
syn match swiftChar / '\( [^'\\ ]\|\\\( ["'tnr0\\ ]\| x[0-9a-fA-F]\{ 2}\| u[0-9a-fA-F]\{ 4}\| U[0-9a-fA-F]\{ 8}\)\) '/
142
150
143
- syn keyword swiftLabel get set
144
-
151
+ syn match swiftPreproc / #\(\< file\>\|\< line\>\) /
145
152
syn match swiftPreproc / ^\s *#\(\< if\>\|\< else\>\|\< elseif\>\|\< endif\>\) /
146
153
syn region swiftPreprocFalse start =" ^\s *#\< if\>\s\+\< false\> " end =" ^\s *#\(\< else\>\|\< elseif\>\|\< endif\>\) "
147
154
148
155
syn match swiftAttribute / @\<\w\+\> / skipwhite nextgroup =swiftType
149
156
150
157
syn keyword swiftTodo TODO FIXME contained
151
- syn keyword swiftNil nil
152
158
159
+ syn match swiftCastOp " \< is\> " skipwhite nextgroup =swiftType
153
160
syn match swiftCastOp " \< as\> [!?]\? " skipwhite nextgroup =swiftType
154
161
155
162
syn match swiftNilOps " ??"
@@ -161,15 +168,14 @@ hi def link swiftImport Include
161
168
hi def link swiftImportModule Title
162
169
hi def link swiftImportComponent Identifier
163
170
hi def link swiftKeyword Statement
171
+ hi def link swiftMultiwordKeyword Statement
164
172
hi def link swiftTypeDefinition Define
165
173
hi def link swiftType Type
166
174
hi def link swiftTypePair Type
167
175
hi def link swiftTypeName Function
168
- hi def link swiftArchetype Identifier
169
176
hi def link swiftConstraint Special
170
177
hi def link swiftFuncDefinition Define
171
178
hi def link swiftDefinitionModifier Define
172
- hi def link swiftFuncName Function
173
179
hi def link swiftFuncKeyword Function
174
180
hi def link swiftFuncKeywordGeneral Function
175
181
hi def link swiftVarDefinition Define
@@ -190,7 +196,6 @@ hi def link swiftBin Number
190
196
hi def link swiftOperator Function
191
197
hi def link swiftChar Character
192
198
hi def link swiftLabel Operator
193
- hi def link swiftNew Operator
194
199
hi def link swiftMutating Statement
195
200
hi def link swiftPreproc PreCondit
196
201
hi def link swiftPreprocFalse Comment
0 commit comments