3# http://www.sublimetext.com/docs/3/syntax.html
7first_line_match: ^#!/.*\bswift
11 - include: shebang-line
16 - include: declaration
17 - include: storage-type
22 - include: documentation-comment
23 - include: block-comment
24 - include: in-line-comment
25 access-level-modifier:
26 - match: \b(open|public|internal|fileprivate|private)\b(?:\(set\))?
27 comment: access-level-modifier
28 scope: keyword.other.access-level-modifier.swift
30 - match: '(?<![/=\-+!*%<>&|\^~.])(\+|\-|\*|\/)(?![/=\-+!*%<>&|\^~.])'
31 scope: keyword.operator.arithmetic.swift
35 1: support.type.array.swift
36 2: punctuation.array.begin.swift
38 - meta_scope: meta.array.swift
41 1: punctuation.array.end.swift
45 - match: '(?<![/=\-+!*%<>&|\^~.])(\+|\-|\*|\/|%|<<|>>|&|\^|\||&&|\|\|)?=(?![/=\-+!*%<>&|\^~.])'
46 scope: keyword.operator.assignment.swift
48 - match: '((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B))(\()'
50 1: storage.modifier.attribute.swift
51 2: punctuation.definition.attribute.swift
52 3: punctuation.definition.attribute-arguments.begin.swift
54 - meta_content_scope: meta.attribute.arguments.swift
57 0: punctuation.definition.attribute-arguments.end.swift
60 - match: '((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B))'
62 1: storage.modifier.attribute.swift
63 2: punctuation.definition.attribute.swift
65 - match: '(?<![/=\-+!*%<>&|\^~.])(&|\||\^|<<|>>)(?![/=\-+!*%<>&|\^~.])'
66 scope: keyword.operator.bitwise.swift
69 comment: Block comment
71 0: punctuation.definition.comment.block.begin.swift
73 - meta_scope: comment.block.swift
76 0: punctuation.definition.comment.block.end.swift
79 - match: \b(true|false)\b
80 scope: keyword.constant.boolean.swift
81 branch-statement-keyword:
82 - include: if-statement-keyword
83 - include: switch-statement-keyword
84 catch-statement-keyword:
85 - match: \b(catch|do)\b
86 comment: catch-statement
87 scope: kewyord.control.catch.swift
92 1: punctuation.definition.code-block.begin.swift
96 1: punctuation.definition.code-block.end.swift
100 - include: array-type
101 - include: dictionary-type
102 - match: \b(Array|Dictionary)\b
103 scope: support.type.swift
104 comparative-operator:
105 - match: '(?<![/=\-+!*%<>&|\^~.])((=|!)==?|(<|>)=?|~=)(?![/=\-+!*%<>&|\^~.])'
106 scope: keyword.operator.comparative.swift
107 control-transfer-statement-keyword:
108 - match: \b(continue|break|fallthrough|return)\b
109 comment: control-transfer-statement
110 scope: keyword.control.transfer.swift
112 - match: '(?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:])'
113 scope: keyword.operator.custom.prefix.unary.swift
114 - match: '(?<![\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:\.])'
115 scope: keyword.operator.custom.postfix.unary.swift
116 - match: '(?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?=[\s)\]},;:])'
117 scope: keyword.operator.custom.binary.swift
119 - include: import-declaration
120 - include: function-declaration
121 declaration-modifier:
122 - match: \b(class|convenience|dynamic|final|lazy|(non)?mutating|optional|override|required|static|unowned((un)?safe)?|weak)\b
123 comment: declaration-modifier
124 scope: keyword.other.declaration-modifier.swift
126 - match: \b(Dictionary)(<)
128 1: support.type.dictionary.swift
129 2: punctuation.dictionary.begin.swift
131 - meta_scope: meta.dictionary.swift
134 1: punctuation.dictionary.end.swift
137 documentation-comment:
139 comment: Documentation comment
141 0: punctuation.definition.comment.block.documentation.begin.swift
143 - meta_scope: comment.block.documentation.swift
146 0: punctuation.definition.comment.block.documentation.end.swift
148 floating-point-literal:
149 - match: '\b([0-9][0-9_]*)(\.([0-9][0-9_]*))?([eE][+\-]?([0-9][0-9_]*))?\b'
150 comment: floating-point-literal -> (decimal-literal)(decimal-fraction)?(decimal-exponent)?
151 - match: '\b(0x\h[\h_]*)(\.(0x\h[\h_]*))?([pP][+\-]?(0x\h[\h_]*))\b'
152 comment: floating-point-literal -> (hexadecimal-literal)(hexadecimal-fraction)?(hexadecimal-exponent)
154 - include: code-block
155 function-declaration:
156 - match: '\b(func)\s+(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B|[/=\-+!*%<>&|\^~.]+)\s*(?=\(|<)'
157 comment: function-declaration
159 1: storage.type.function.swift
160 2: entity.type.function.swift
162 - meta_scope: meta.function-declaration.swift
165 - include: generic-parameter-clause
166 - include: parameter-clause
167 - include: function-result
168 - include: function-body
170 - match: '(?<![/=\-+!*%<>&|\^~.])(\->)(?![/=\-+!*%<>&|\^~.])\s*'
171 comment: function-result
173 1: keyword.operator.function-result.swift
175 - meta_scope: meta.function-result.swift
179 generic-parameter-clause:
181 comment: generic-parameter-clause
183 1: punctuation.definition.generic-parameter-clause.begin.swift
185 - meta_scope: meta.generic-parameter-clause.swift
188 1: punctuation.definition.generic-parameter-clause.end.swift
192 - match: '(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B)'
194 scope: meta.identifier.swift
195 if-statement-keyword:
196 - match: \b(if|else)\b
197 comment: if-statement
198 scope: keyword.control.if.swift
200 - match: '\b(import)\s+(?:(typealias|struct|class|enum|protocol|var|func)\s+)?((?:\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B|[/=\-+!*%<>&|\^~.]+)(?:\.(?:\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B|[/=\-+!*%<>&|\^~.]+))*)'
201 comment: import-declaration
202 scope: meta.import.swift
204 1: keyword.other.import.swift
205 2: storage.modifier.swift
206 3: support.type.module.import.swift
209 comment: In-line comment
210 scope: comment.line.double-slash.swift
212 1: punctuation.definition.comment.line.double-slash.swift
213 increment-decrement-operator:
214 - match: '(?<![/=\-+!*%<>&|\^~.])(\+\+|\-\-)(?![/=\-+!*%<>&|\^~.])'
215 scope: keyword.operator.increment-or-decrement.swift
217 - match: '(\B\-|\b)(0b[01][01_]*)\b'
218 comment: binary-literal
219 scope: constant.numeric.integer.binary.swift
220 - match: '(\B\-|\b)(0o[0-7][0-7_]*)\b'
221 comment: octal-literal
222 scope: constant.numeric.integer.octal.swift
223 - match: '(\B\-|\b)([0-9][0-9_]*)\b'
224 comment: decimal-literal
225 scope: constant.numeric.integer.decimal.swift
226 - match: '(\B\-|\b)(0x\h[\h_]*)\b'
227 comment: hexadecimal-literal
228 scope: constant.numeric.integer.hexadecimal.swift
230 - match: \bU?Int(8|16|32|64)?\b
232 scope: support.type.swift
234 - include: branch-statement-keyword
235 - include: control-transfer-statement-keyword
236 - include: loop-statement-keyword
237 - include: catch-statement-keyword
238 - include: operator-declaration-modifier
239 - include: declaration-modifier
240 - include: access-level-modifier
241 - match: \b(class|deinit|enum|extension|func|import|init|let|protocol|static|struct|subscript|typealias|var|throws|rethrows)\b
242 comment: declaration keyword
243 scope: keyword.declaration.swift
244 - match: \b(break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|repeat|catch|guard|defer|try|throw)\b
245 comment: statement keyword
246 scope: keyword.statement.swift
247 - match: \b(as|dynamicType|is|new|super|self|Self|Type)\b
248 comment: expression and type keyword
249 scope: keyword.other.statement.swift
250 - match: \b(associativity|didSet|get|infix|inout|left|mutating|none|nonmutating|operator|override|postfix|precedence|prefix|right|set|unowned((un)?safe)?|weak|willSet)\b
251 comment: other keyword
252 scope: keyword.other.swift
254 - include: integer-literal
255 - include: floating-point-literal
256 - include: nil-literal
257 - include: string-literal
258 - include: special-literal
260 - match: '(?<![/=\-+!*%<>&|\^~.])(!|&&|\|\|)(?![/=\-+!*%<>&|\^~.])'
261 scope: keyword.operator.logical.swift
262 loop-statement-keyword:
263 - match: \b(while|repeat|for|in)\b
264 comment: loop-statement
265 scope: keyword.control.loop.swift
269 scope: constant.nil.swift
271 - include: comparative-operator
272 - include: assignment-operator
273 - include: logical-operator
274 - include: remainder-operator
275 - include: increment-decrement-operator
276 - include: overflow-operator
277 - include: range-operator
278 - include: bitwise-operator
279 - include: arithmetic-operator
280 - include: ternary-operator
281 - include: type-casting-operator
282 - include: custom-operator
283 operator-declaration-modifier:
284 - match: \b(operator|prefix|infix|postfix)\b
285 comment: operator-declaration
286 scope: keyword.other.operator.swift
288 - match: \b(Optional)(<)
289 scope: meta.optional.swift
291 - match: '(?<![/=\-+!*%<>&|\^~.])\&(\+|\-|\*|\/|%)(?![/=\-+!*%<>&|\^~.])'
292 scope: keyword.operator.overflow.swift
295 comment: parameter-clause
297 1: punctuation.definition.function-arguments.begin.swift
299 - meta_scope: meta.parameter-clause.swift
302 1: punctuation.definition.function-arguments.end.swift
306 - match: \b(Int|Float|Double|String|Bool|Character|Void)\b
307 comment: Primitive types
308 scope: support.type.swift
309 protocol-composition-type:
310 - match: \b(protocol)(<)
311 scope: meta.protocol.swift
313 - match: '(?<![/=\-+!*%<>&|\^~.])\.\.(?:\.)?(?![/=\-+!*%<>&|\^~.])'
314 scope: keyword.operator.range.swift
316 - match: '(?<![/=\-+!*%<>&|\^~.])\%(?![/=\-+!*%<>&|\^~.])'
317 scope: keyword.operator.remainder.swift
320 comment: Shebang line
321 scope: comment.line.shebang.swift
323 1: punctuation.definition.comment.line.shebang.swift
325 - match: \b__(FILE|LINE|COLUMN|FUNCTION)__\b
326 scope: keyword.other.literal.swift
328 - match: \b(var|func|let|class|enum|struct|protocol|extension|typealias)\b
329 scope: storage.type.swift
333 0: string.quoted.double.swift
335 - meta_scope: meta.literal.string.swift
338 0: string.quoted.double.swift
340 - match: '\\([0tnr\"\''\\]|x\h{2}|u\h{4}|U\h{8})'
341 scope: constant.character.escape.swift
344 1: support.punctuation.expression.begin.swift
346 - meta_content_scope: meta.expression.swift
349 1: support.punctuation.expression.end.swift
351 - include: scope:source.swift
353 scope: invalid.illegal.swift
355 scope: string.quoted.double.swift
356 switch-statement-keyword:
357 - match: \b(switch|case|default|where)\b
358 comment: switch-statement
359 scope: keyword.control.switch.swift
361 - match: '(?<=[\s(\[{,;:])(\?|:)(?=[\s)\]},;:])'
362 scope: keyword.operator.ternary.swift
364 - include: primitive-type
365 - include: integer-type
366 - include: collection-type
367 - include: optional-type
368 - include: protocol-composition-type
369 type-casting-operator:
370 - match: \b(is\b|as(\?\B|\b))
371 scope: keyword.operator.type-casting.swift
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list