Skip to content

Commit a756131

Browse files
committed
vim: more clever highlighting of generics
Perform more clever highlighting of generic clauses. The archetype identifier is now identified as an identifier, the archtetype type as a type, and the constraints (where) as special syntax.
1 parent 5fd99ae commit a756131

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

utils/vim/syntax/swift.vim

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,13 @@ syn region swiftType contained contains=swiftType,swiftParamDelim
101101
\ start="[^@](" end=")"
102102
syn match swiftParamDelim contained
103103
\ /,/
104-
105-
syn region swiftTypeParameters start="<" end=">" contained
104+
" <Generic Clause> (generics)
105+
syn region swiftTypeParameters contained contains=swiftArchetype,swiftConstraint
106+
\ start="<" end=">"
107+
syn match swiftArchetype contained skipwhite nextgroup=swiftColonType
108+
\ /\<[A-Za-z_][A-Za-z_0-9]*\>/
109+
syn keyword swiftConstraint contained
110+
\ where
106111

107112
syn keyword swiftMutating mutating skipwhite nextgroup=swiftFuncDefinition
108113
syn keyword swiftFuncDefinition func skipwhite nextgroup=swiftFuncName,swiftOperator
@@ -156,7 +161,8 @@ hi def link swiftTypeDefinition Define
156161
hi def link swiftType Type
157162
hi def link swiftTypePair Type
158163
hi def link swiftTypeName Function
159-
hi def link swiftTypeParameters Special
164+
hi def link swiftArchetype Identifier
165+
hi def link swiftConstraint Special
160166
hi def link swiftFuncDefinition Define
161167
hi def link swiftDefinitionModifier Define
162168
hi def link swiftFuncName Function
@@ -167,6 +173,7 @@ hi def link swiftVarName Identifier
167173
hi def link swiftImplicitVarName Identifier
168174
hi def link swiftIdentifierKeyword Identifier
169175
hi def link swiftTypeDeclaration Delimiter
176+
hi def link swiftTypeParameters Delimiter
170177
hi def link swiftBoolean Boolean
171178
hi def link swiftString String
172179
hi def link swiftInterpolation Special

0 commit comments

Comments
 (0)