├── Snippets ├── Array.sublime-snippet ├── enum.sublime-snippet ├── Dictionary.sublime-snippet ├── class-var.sublime-snippet ├── get.sublime-snippet ├── set.sublime-snippet ├── else.sublime-snippet ├── func.sublime-snippet ├── static-var.sublime-snippet ├── if.sublime-snippet ├── deinit.sublime-snippet ├── didSet.sublime-snippet ├── class.sublime-snippet ├── struct.sublime-snippet ├── willSet.sublime-snippet ├── typealias.sublime-snippet ├── else-if.sublime-snippet ├── init.sublime-snippet ├── protocol.sublime-snippet ├── extension.sublime-snippet ├── swift.sublime-snippet ├── operator.sublime-snippet ├── if-else.sublime-snippet ├── subscript.sublime-snippet └── switch.sublime-snippet ├── Key Bindings ├── Default (Linux).sublime-keymap ├── Default (OSX).sublime-keymap └── Default (Windows).sublime-keymap ├── Preferences └── Comments.tmPreferences ├── LICENSE ├── README.md └── Syntaxes ├── Swift.YAML-tmLanguage ├── Swift.JSON-tmLanguage └── Swift.tmLanguage /Snippets/Array.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 4 | ]]> 5 | Array 6 | source.swift 7 | 8 | -------------------------------------------------------------------------------- /Snippets/enum.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | enum 8 | source.swift 9 | 10 | -------------------------------------------------------------------------------- /Snippets/Dictionary.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 4 | ]]> 5 | Dictionary 6 | source.swift 7 | 8 | -------------------------------------------------------------------------------- /Snippets/class-var.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 5 | cv 6 | source.swift 7 | class var ... 8 | 9 | -------------------------------------------------------------------------------- /Snippets/get.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | get 8 | source.swift 9 | get {...} 10 | 11 | -------------------------------------------------------------------------------- /Snippets/set.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | set 8 | source.swift 9 | set {...} 10 | 11 | -------------------------------------------------------------------------------- /Snippets/else.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | else 8 | source.swift 9 | else ... 10 | 11 | -------------------------------------------------------------------------------- /Snippets/func.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | ${3:ReturnType} { 4 | $4 5 | } 6 | ]]> 7 | func 8 | source.swift 9 | 10 | -------------------------------------------------------------------------------- /Snippets/static-var.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 5 | sv 6 | source.swift 7 | static var ... 8 | 9 | -------------------------------------------------------------------------------- /Snippets/if.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | if 8 | source.swift 9 | if ... 10 | 11 | -------------------------------------------------------------------------------- /Snippets/deinit.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | deinit 8 | source.swift 9 | deinit {...} 10 | 11 | -------------------------------------------------------------------------------- /Snippets/didSet.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | didSet 8 | source.swift 9 | didSet {...} 10 | 11 | -------------------------------------------------------------------------------- /Snippets/class.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | class 8 | source.swift 9 | class ... 10 | 11 | -------------------------------------------------------------------------------- /Snippets/struct.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | struct 8 | source.swift 9 | struct ... 10 | 11 | -------------------------------------------------------------------------------- /Snippets/willSet.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | willSet 8 | source.swift 9 | willSet {...} 10 | 11 | -------------------------------------------------------------------------------- /Snippets/typealias.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 5 | typealias 6 | source.swift 7 | typealias ... = ... 8 | 9 | -------------------------------------------------------------------------------- /Snippets/else-if.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | elif 8 | source.swift 9 | else if ... 10 | 11 | -------------------------------------------------------------------------------- /Snippets/init.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | init 8 | source.swift 9 | init(...) {...} 10 | 11 | -------------------------------------------------------------------------------- /Snippets/protocol.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | protocol 8 | source.swift 9 | protocol ... 10 | 11 | -------------------------------------------------------------------------------- /Snippets/extension.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | extension 8 | source.swift 9 | extension ... 10 | 11 | -------------------------------------------------------------------------------- /Snippets/swift.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 6 | swift 7 | source.swift 8 | #!/usr/bin/env xcrun swift 9 | 10 | -------------------------------------------------------------------------------- /Snippets/operator.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 7 | operator 8 | source.swift 9 | operator ... 10 | 11 | -------------------------------------------------------------------------------- /Snippets/if-else.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 9 | ifelse 10 | source.swift 11 | if ... else ... 12 | 13 | -------------------------------------------------------------------------------- /Snippets/subscript.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | ${2:ReturnType} { 4 | $3 5 | } 6 | ]]> 7 | subscript 8 | source.swift 9 | subscript ... 10 | 11 | -------------------------------------------------------------------------------- /Snippets/switch.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 8 | switch 9 | source.swift 10 | switch ... 11 | 12 | -------------------------------------------------------------------------------- /Key Bindings/Default (Linux).sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | // Auto-pair parentheses for expressions inside string literals 3 | { "keys": ["("], "command": "insert_snippet", "args": {"contents": "($0)"}, "context": 4 | [ 5 | { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 6 | { "key": "selector", "operator": "equal", "operand": "source.swift meta.literal.string", "match_all": true }, 7 | { "key": "preceding_text", "operator": "regex_match", "operand": ".*(?:[^\\\\](?:[\\\\]{2})*+\\\\)$", "match_all": true } 8 | ] 9 | } 10 | ] -------------------------------------------------------------------------------- /Key Bindings/Default (OSX).sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | // Auto-pair parentheses for expressions inside string literals 3 | { "keys": ["("], "command": "insert_snippet", "args": {"contents": "($0)"}, "context": 4 | [ 5 | { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 6 | { "key": "selector", "operator": "equal", "operand": "source.swift meta.literal.string", "match_all": true }, 7 | { "key": "preceding_text", "operator": "regex_match", "operand": ".*(?:[^\\\\](?:[\\\\]{2})*+\\\\)$", "match_all": true } 8 | ] 9 | } 10 | ] -------------------------------------------------------------------------------- /Key Bindings/Default (Windows).sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | // Auto-pair parentheses for expressions inside string literals 3 | { "keys": ["("], "command": "insert_snippet", "args": {"contents": "($0)"}, "context": 4 | [ 5 | { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 6 | { "key": "selector", "operator": "equal", "operand": "source.swift meta.literal.string", "match_all": true }, 7 | { "key": "preceding_text", "operator": "regex_match", "operand": ".*(?:[^\\\\](?:[\\\\]{2})*+\\\\)$", "match_all": true } 8 | ] 9 | } 10 | ] -------------------------------------------------------------------------------- /Preferences/Comments.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Comments 7 | scope 8 | source.swift 9 | settings 10 | 11 | shellVariables 12 | 13 | 14 | name 15 | TM_COMMENT_START 16 | value 17 | // 18 | 19 | 20 | name 21 | TM_COMMENT_START_2 22 | value 23 | /* 24 | 25 | 26 | name 27 | TM_COMMENT_END_2 28 | value 29 | */ 30 | 31 | 32 | 33 | uuid 34 | e4dfd8f5-d016-4899-b491-d46e5d32b3a3 35 | 36 | 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Matthew Alexander 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Swift-Sublime-Package 2 | 3 | A [Sublime Text](http://www.sublimetext.com/) package for the [Swift programming language](https://developer.apple.com/swift/) 4 | 5 | ## Installation 6 | 7 | ### via Package Control (Recommended) 8 | [Package Control](http://wbond.net/sublime_packages/package_control) is a package manager for Sublime Text 2 & 3. If you don't already have it installed, follow the [installation instructions here](https://sublime.wbond.net/installation). 9 | 10 | Once Package Control is installed, restart Sublime and follow these steps: 11 | * Open the Command Pallette (`cmd + shift + p` on OS X / Linux or `ctrl + shift + p` on Windows) 12 | * Type "install" and select "Package Control: Install Package" 13 | * Type "swift" and press Enter 14 | 15 | All done! Package Control will automatically update the package whenever there's a new version. 16 | 17 | ## License 18 | 19 | The MIT License (MIT) 20 | 21 | Copyright (c) 2014 Matthew Alexander 22 | 23 | Permission is hereby granted, free of charge, to any person obtaining a copy 24 | of this software and associated documentation files (the "Software"), to deal 25 | in the Software without restriction, including without limitation the rights 26 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 27 | copies of the Software, and to permit persons to whom the Software is 28 | furnished to do so, subject to the following conditions: 29 | 30 | The above copyright notice and this permission notice shall be included in 31 | all copies or substantial portions of the Software. 32 | 33 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 34 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 35 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 36 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 37 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 38 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 39 | THE SOFTWARE. 40 | -------------------------------------------------------------------------------- /Syntaxes/Swift.YAML-tmLanguage: -------------------------------------------------------------------------------- 1 | # author: Matt Alexander - matt@queg.net 2 | # [PackageDev] target_format: plist, source_format: yaml, ext: tmLanguage 3 | # [PackageDev] target_format: json, source_format: yaml, ext: JSON-tmLanguage 4 | --- 5 | name: Swift 6 | scopeName: source.swift 7 | author: Matt Alexander - matt@queg.net 8 | fileTypes: [swift] 9 | uuid: 7efa1168-97c3-4433-8dd7-15b99bf3bb53 10 | keyEquivalent: ^~S 11 | firstLineMatch: ^#!/.*\bswift 12 | 13 | patterns: 14 | - include: '#shebang-line' 15 | - include: '#comment' 16 | - include: '#attribute' 17 | - include: '#literal' 18 | - include: '#operator' 19 | - include: '#declaration' 20 | - include: '#storage-type' 21 | - include: '#keyword' 22 | - include: '#type' 23 | - include: '#boolean' 24 | 25 | repository: 26 | 27 | # Identifier 28 | identifier: 29 | comment: identifier 30 | name: meta.identifier.swift 31 | match: (\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B) 32 | 33 | 34 | # Keywords 35 | keyword: 36 | patterns: 37 | - include: '#branch-statement-keyword' 38 | - include: '#control-transfer-statement-keyword' 39 | - include: '#loop-statement-keyword' 40 | - include: '#catch-statement-keyword' 41 | - include: '#operator-declaration-modifier' 42 | - include: '#declaration-modifier' 43 | - include: '#access-level-modifier' 44 | - comment: declaration keyword 45 | name: keyword.declaration.swift 46 | match: \b(class|deinit|enum|extension|func|import|init|let|protocol|static|struct|subscript|typealias|var|throws|rethrows)\b 47 | - comment: statement keyword 48 | name: keyword.statement.swift 49 | match: \b(break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|repeat|catch|guard|defer|try|throw)\b 50 | - comment: expression and type keyword 51 | name: keyword.other.statement.swift 52 | match: \b(as|dynamicType|is|new|super|self|Self|Type)\b 53 | - comment: other keyword 54 | name: keyword.other.swift 55 | match: \b(associativity|didSet|get|infix|inout|left|mutating|none|nonmutating|operator|override|postfix|precedence|prefix|right|set|unowned((un)?safe)?|weak|willSet)\b 56 | branch-statement-keyword: 57 | name: keyword.control.branch.swift 58 | patterns: 59 | - include: '#if-statement-keyword' 60 | - include: '#switch-statement-keyword' 61 | switch-statement-keyword: 62 | comment: switch-statement 63 | name: keyword.control.switch.swift 64 | match: \b(switch|case|default|where)\b 65 | if-statement-keyword: 66 | comment: if-statement 67 | name: keyword.control.if.swift 68 | match: \b(if|else)\b 69 | control-transfer-statement-keyword: 70 | comment: control-transfer-statement 71 | name: keyword.control.transfer.swift 72 | match: \b(continue|break|fallthrough|return)\b 73 | loop-statement-keyword: 74 | comment: loop-statement 75 | name: keyword.control.loop.swift 76 | match: \b(while|repeat|for|in)\b 77 | catch-statement-keyword: 78 | comment: catch-statement 79 | name: kewyord.control.catch.swift 80 | match: \b(catch|do)\b 81 | operator-declaration-modifier: 82 | comment: operator-declaration 83 | name: keyword.other.operator.swift 84 | match: \b(operator|prefix|infix|postfix)\b 85 | access-level-modifier: 86 | comment: access-level-modifier 87 | name: keyword.other.access-level-modifier.swift 88 | match: \b(open|public|internal|fileprivate|private)\b(?:\(set\))? 89 | declaration-modifier: 90 | comment: declaration-modifier 91 | name: keyword.other.declaration-modifier.swift 92 | match: \b(class|convenience|dynamic|final|lazy|(non)?mutating|optional|override|required|static|unowned((un)?safe)?|weak)\b 93 | 94 | 95 | # Storage types 96 | storage-type: 97 | name: storage.type.swift 98 | match: \b(var|func|let|class|enum|struct|protocol|extension|typealias)\b 99 | 100 | 101 | # Operators 102 | operator: 103 | patterns: 104 | - include: '#comparative-operator' 105 | - include: '#assignment-operator' 106 | - include: '#logical-operator' 107 | - include: '#remainder-operator' 108 | - include: '#increment-decrement-operator' 109 | - include: '#overflow-operator' 110 | - include: '#range-operator' 111 | - include: '#bitwise-operator' 112 | - include: '#arithmetic-operator' 113 | - include: '#ternary-operator' 114 | - include: '#type-casting-operator' 115 | - include: '#custom-operator' 116 | comparative-operator: 117 | name: keyword.operator.comparative.swift 118 | match: (?&|\^~.])((=|!)==?|(<|>)=?|~=)(?![/=\-+!*%<>&|\^~.]) 119 | assignment-operator: 120 | name: keyword.operator.assignment.swift 121 | match: (?&|\^~.])(\+|\-|\*|\/|%|<<|>>|&|\^|\||&&|\|\|)?=(?![/=\-+!*%<>&|\^~.]) 122 | logical-operator: 123 | name: keyword.operator.logical.swift 124 | match: (?&|\^~.])(!|&&|\|\|)(?![/=\-+!*%<>&|\^~.]) 125 | remainder-operator: 126 | name: keyword.operator.remainder.swift 127 | match: (?&|\^~.])\%(?![/=\-+!*%<>&|\^~.]) 128 | increment-decrement-operator: 129 | name: keyword.operator.increment-or-decrement.swift 130 | match: (?&|\^~.])(\+\+|\-\-)(?![/=\-+!*%<>&|\^~.]) 131 | overflow-operator: 132 | name: keyword.operator.overflow.swift 133 | match: (?&|\^~.])\&(\+|\-|\*|\/|%)(?![/=\-+!*%<>&|\^~.]) 134 | range-operator: 135 | name: keyword.operator.range.swift 136 | match: (?&|\^~.])\.\.(?:\.)?(?![/=\-+!*%<>&|\^~.]) 137 | arithmetic-operator: 138 | name: keyword.operator.arithmetic.swift 139 | match: (?&|\^~.])(\+|\-|\*|\/)(?![/=\-+!*%<>&|\^~.]) 140 | bitwise-operator: 141 | name: keyword.operator.bitwise.swift 142 | match: (?&|\^~.])(&|\||\^|<<|>>)(?![/=\-+!*%<>&|\^~.]) 143 | ternary-operator: 144 | name: keyword.operator.ternary.swift 145 | match: (?<=[\s(\[{,;:])(\?|:)(?=[\s)\]},;:]) 146 | type-casting-operator: 147 | name: keyword.operator.type-casting.swift 148 | match: \b(is\b|as(\?\B|\b)) 149 | custom-operator: 150 | patterns: 151 | - name: keyword.operator.custom.prefix.unary.swift 152 | match: (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:]) 153 | - name: keyword.operator.custom.postfix.unary.swift 154 | match: (?&|\^~.]++)(?![\s)\]},;:\.]) 155 | - name: keyword.operator.custom.binary.swift 156 | match: (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?=[\s)\]},;:]) 157 | 158 | 159 | # Literal Expressions 160 | literal: 161 | patterns: 162 | - include: '#integer-literal' 163 | - include: '#floating-point-literal' 164 | - include: '#nil-literal' 165 | - include: '#string-literal' 166 | - include: '#special-literal' 167 | integer-literal: 168 | name: constant.numeric.integer.swift 169 | patterns: 170 | - comment: binary-literal 171 | name: constant.numeric.integer.binary.swift 172 | match: (\B\-|\b)(0b[01][01_]*)\b 173 | - comment: octal-literal 174 | name: constant.numeric.integer.octal.swift 175 | match: (\B\-|\b)(0o[0-7][0-7_]*)\b 176 | - comment: decimal-literal 177 | name: constant.numeric.integer.decimal.swift 178 | match: (\B\-|\b)([0-9][0-9_]*)\b 179 | - comment: hexadecimal-literal 180 | name: constant.numeric.integer.hexadecimal.swift 181 | match: (\B\-|\b)(0x\h[\h_]*)\b 182 | floating-point-literal: 183 | name: constant.numeric.floating-point.swift 184 | patterns: 185 | - comment: floating-point-literal -> (decimal-literal)(decimal-fraction)?(decimal-exponent)? 186 | match: \b([0-9][0-9_]*)(\.([0-9][0-9_]*))?([eE][+\-]?([0-9][0-9_]*))?\b 187 | - comment: floating-point-literal -> (hexadecimal-literal)(hexadecimal-fraction)?(hexadecimal-exponent) 188 | match: \b(0x\h[\h_]*)(\.(0x\h[\h_]*))?([pP][+\-]?(0x\h[\h_]*))\b 189 | nil-literal: 190 | comment: nil-literal 191 | name: constant.nil.swift 192 | match: \bnil\b 193 | string-literal: 194 | name: meta.literal.string.swift 195 | begin: \" 196 | end: \" 197 | beginCaptures: 198 | '0': { name: string.quoted.double.swift } 199 | endCaptures: 200 | '0': { name: string.quoted.double.swift } 201 | patterns: 202 | - name: constant.character.escape.swift 203 | match: \\([0tnr\"\'\\]|x\h{2}|u\h{4}|U\h{8}) 204 | - contentName: meta.expression.swift 205 | begin: (\\\() 206 | end: (\)) 207 | beginCaptures: 208 | '1': { name: support.punctuation.expression.begin.swift } 209 | endCaptures: 210 | '1': { name: support.punctuation.expression.end.swift } 211 | patterns: 212 | - include: source.swift 213 | - name: invalid.illegal.swift 214 | match: (\"|\\) 215 | - name: string.quoted.double.swift 216 | match: (.) 217 | special-literal: 218 | name: keyword.other.literal.swift 219 | match: \b__(FILE|LINE|COLUMN|FUNCTION)__\b 220 | 221 | 222 | # Primitive values 223 | boolean: 224 | name: keyword.constant.boolean.swift 225 | match: \b(true|false)\b 226 | 227 | 228 | # Type names 229 | type: 230 | comment: type 231 | patterns: 232 | - include: '#primitive-type' 233 | - include: '#integer-type' 234 | - include: '#collection-type' 235 | - include: '#optional-type' 236 | - include: '#protocol-composition-type' 237 | primitive-type: 238 | comment: Primitive types 239 | name: support.type.swift 240 | match: \b(Int|Float|Double|String|Bool|Character|Void)\b 241 | integer-type: 242 | comment: Int types 243 | name: support.type.swift 244 | match: \bU?Int(8|16|32|64)?\b 245 | collection-type: 246 | comment: Collection types 247 | patterns: 248 | - include: '#array-type' 249 | - include: '#dictionary-type' 250 | - name: support.type.swift 251 | match: \b(Array|Dictionary)\b 252 | array-type: 253 | name: meta.array.swift 254 | begin: \b(Array)(<) 255 | end: (>) 256 | beginCaptures: 257 | '1': { name: support.type.array.swift } 258 | '2': { name: punctuation.array.begin.swift } 259 | endCaptures: 260 | '1': {name: punctuation.array.end.swift} 261 | patterns: 262 | - include: $self 263 | dictionary-type: 264 | name: meta.dictionary.swift 265 | begin: \b(Dictionary)(<) 266 | end: (>) 267 | beginCaptures: 268 | '1': { name: support.type.dictionary.swift } 269 | '2': { name: punctuation.dictionary.begin.swift } 270 | endCaptures: 271 | '1': {name: punctuation.dictionary.end.swift} 272 | patterns: 273 | - include: $self 274 | optional-type: 275 | name: meta.optional.swift 276 | match: \b(Optional)(<) 277 | end: (>) 278 | beginCaptures: 279 | '1': { name: support.type.optional.swift } 280 | '2': { name: punctuation.optional.begin.swift } 281 | endCaptures: 282 | '1': { name: punctuation.optional.end.swift } 283 | patterns: 284 | - include: $self 285 | protocol-composition-type: 286 | name: meta.protocol.swift 287 | match: \b(protocol)(<) 288 | end: (>) 289 | beginCaptures: 290 | '1': { name: support.type.protocol.swift } 291 | '2': { name: punctuation.protocol.begin.swift } 292 | endCaptures: 293 | '1': { name: punctuation.protocol.end.swift } 294 | patterns: 295 | - include: $self 296 | 297 | # Attributes 298 | attribute: 299 | comment: attribute 300 | name: meta.attribute.swift 301 | patterns: 302 | - begin: ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B))(\() 303 | end: \) 304 | contentName: meta.attribute.arguments.swift 305 | beginCaptures: 306 | '1': { name: storage.modifier.attribute.swift } 307 | '2': { name: punctuation.definition.attribute.swift } 308 | '3': { name: punctuation.definition.attribute-arguments.begin.swift } 309 | endCaptures: 310 | '0': { name: punctuation.definition.attribute-arguments.end.swift } 311 | patterns: 312 | - include: $self 313 | - match: ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B)) 314 | captures: 315 | '1': { name: storage.modifier.attribute.swift } 316 | '2': { name: punctuation.definition.attribute.swift } 317 | 318 | 319 | # Declarations 320 | declaration: 321 | comment: declaration 322 | name: meta.declaration.swift 323 | patterns: 324 | - include: '#import-declaration' 325 | - include: '#function-declaration' 326 | 327 | # Import Declaration 328 | import-declaration: 329 | comment: import-declaration 330 | name: meta.import.swift 331 | 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|[/=\-+!*%<>&|\^~.]+))*) 332 | captures: 333 | '1': { name: keyword.other.import.swift } 334 | '2': { name: storage.modifier.swift } 335 | '3': { name: support.type.module.import.swift } 336 | 337 | # Function Declaration 338 | function-declaration: 339 | comment: function-declaration 340 | name: meta.function-declaration.swift 341 | begin: \b(func)\s+(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B|[/=\-+!*%<>&|\^~.]+)\s*(?=\(|<) 342 | end: (?<=\}) 343 | beginCaptures: 344 | '1': { name: storage.type.function.swift } 345 | '2': { name: entity.type.function.swift } 346 | patterns: 347 | - include: '#generic-parameter-clause' 348 | - include: '#parameter-clause' 349 | - include: '#function-result' 350 | - include: '#function-body' 351 | parameter-clause: 352 | comment: parameter-clause 353 | name: meta.parameter-clause.swift 354 | begin: (\() 355 | end: (\)) 356 | beginCaptures: 357 | '1': { name: punctuation.definition.function-arguments.begin.swift } 358 | endCaptures: 359 | '1': { name: punctuation.definition.function-arguments.end.swift } 360 | patterns: 361 | - include: $self 362 | function-result: 363 | comment: function-result 364 | name: meta.function-result.swift 365 | begin: (?&|\^~.])(\->)(?![/=\-+!*%<>&|\^~.])\s* 366 | end: \s*(?=\{) 367 | beginCaptures: 368 | '1': { name: keyword.operator.function-result.swift } 369 | patterns: 370 | - include: '#type' 371 | function-body: 372 | comment: function-body 373 | name: meta.function-body.swift 374 | patterns: 375 | - include: '#code-block' 376 | 377 | 378 | generic-parameter-clause: 379 | comment: generic-parameter-clause 380 | name: meta.generic-parameter-clause.swift 381 | begin: (<) 382 | end: (>) 383 | beginCaptures: 384 | '1': { name: punctuation.definition.generic-parameter-clause.begin.swift } 385 | endCaptures: 386 | '1': { name: punctuation.definition.generic-parameter-clause.end.swift } 387 | patterns: 388 | - include: $self 389 | 390 | code-block: 391 | comment: code-block 392 | begin: (\{) 393 | end: (\}) 394 | beginCaptures: 395 | '1': { name: punctuation.definition.code-block.begin.swift } 396 | endCaptures: 397 | '1': { name: punctuation.definition.code-block.end.swift } 398 | patterns: 399 | - include: $self 400 | 401 | 402 | # Comments 403 | comment: 404 | comment: All comment types 405 | patterns: 406 | - include: '#documentation-comment' 407 | - include: '#block-comment' 408 | - include: '#in-line-comment' 409 | documentation-comment: 410 | comment: Documentation comment 411 | name: comment.block.documentation.swift 412 | begin: /\*\* 413 | end: \*/ 414 | beginCaptures: 415 | '0': { name: punctuation.definition.comment.block.documentation.begin.swift } 416 | endCaptures: 417 | '0': { name: punctuation.definition.comment.block.documentation.end.swift } 418 | block-comment: 419 | comment: Block comment 420 | name: comment.block.swift 421 | begin: /\* 422 | end: \*/ 423 | beginCaptures: 424 | '0': { name: punctuation.definition.comment.block.begin.swift } 425 | endCaptures: 426 | '0': { name: punctuation.definition.comment.block.end.swift } 427 | in-line-comment: 428 | comment: In-line comment 429 | name: comment.line.double-slash.swift 430 | match: (//).* 431 | captures: 432 | '1': { name: punctuation.definition.comment.line.double-slash.swift } 433 | 434 | shebang-line: 435 | comment: Shebang line 436 | name: comment.line.shebang.swift 437 | match: ^(#!).*$ 438 | captures: 439 | '1': { name: punctuation.definition.comment.line.shebang.swift } 440 | 441 | ... 442 | -------------------------------------------------------------------------------- /Syntaxes/Swift.JSON-tmLanguage: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Swift", 3 | "scopeName": "source.swift", 4 | "firstLineMatch": "^#!/.*\\bswift", 5 | "uuid": "7efa1168-97c3-4433-8dd7-15b99bf3bb53", 6 | "repository": { 7 | "custom-operator": { 8 | "patterns": [ 9 | { 10 | "name": "keyword.operator.custom.prefix.unary.swift", 11 | "match": "(?<=[\\s(\\[{,;:])([/=\\-+!*%<>&|\\^~.]++)(?![\\s)\\]},;:])" 12 | }, 13 | { 14 | "name": "keyword.operator.custom.postfix.unary.swift", 15 | "match": "(?&|\\^~.]++)(?![\\s)\\]},;:\\.])" 16 | }, 17 | { 18 | "name": "keyword.operator.custom.binary.swift", 19 | "match": "(?<=[\\s(\\[{,;:])([/=\\-+!*%<>&|\\^~.]++)(?=[\\s)\\]},;:])" 20 | } 21 | ] 22 | }, 23 | "operator-declaration-modifier": { 24 | "comment": "operator-declaration", 25 | "name": "keyword.other.operator.swift", 26 | "match": "\\b(operator|prefix|infix|postfix)\\b" 27 | }, 28 | "if-statement-keyword": { 29 | "comment": "if-statement", 30 | "name": "keyword.control.if.swift", 31 | "match": "\\b(if|else)\\b" 32 | }, 33 | "protocol-composition-type": { 34 | "endCaptures": { 35 | "1": { 36 | "name": "punctuation.protocol.end.swift" 37 | } 38 | }, 39 | "match": "\\b(protocol)(<)", 40 | "beginCaptures": { 41 | "1": { 42 | "name": "support.type.protocol.swift" 43 | }, 44 | "2": { 45 | "name": "punctuation.protocol.begin.swift" 46 | } 47 | }, 48 | "patterns": [ 49 | { 50 | "include": "$self" 51 | } 52 | ], 53 | "end": "(>)", 54 | "name": "meta.protocol.swift" 55 | }, 56 | "overflow-operator": { 57 | "name": "keyword.operator.overflow.swift", 58 | "match": "(?&|\\^~.])\\&(\\+|\\-|\\*|\\/|%)(?![/=\\-+!*%<>&|\\^~.])" 59 | }, 60 | "operator": { 61 | "patterns": [ 62 | { 63 | "include": "#comparative-operator" 64 | }, 65 | { 66 | "include": "#assignment-operator" 67 | }, 68 | { 69 | "include": "#logical-operator" 70 | }, 71 | { 72 | "include": "#remainder-operator" 73 | }, 74 | { 75 | "include": "#increment-decrement-operator" 76 | }, 77 | { 78 | "include": "#overflow-operator" 79 | }, 80 | { 81 | "include": "#range-operator" 82 | }, 83 | { 84 | "include": "#bitwise-operator" 85 | }, 86 | { 87 | "include": "#arithmetic-operator" 88 | }, 89 | { 90 | "include": "#ternary-operator" 91 | }, 92 | { 93 | "include": "#type-casting-operator" 94 | }, 95 | { 96 | "include": "#custom-operator" 97 | } 98 | ] 99 | }, 100 | "type-casting-operator": { 101 | "name": "keyword.operator.type-casting.swift", 102 | "match": "\\b(is\\b|as(\\?\\B|\\b))" 103 | }, 104 | "type": { 105 | "comment": "type", 106 | "patterns": [ 107 | { 108 | "include": "#primitive-type" 109 | }, 110 | { 111 | "include": "#integer-type" 112 | }, 113 | { 114 | "include": "#collection-type" 115 | }, 116 | { 117 | "include": "#optional-type" 118 | }, 119 | { 120 | "include": "#protocol-composition-type" 121 | } 122 | ] 123 | }, 124 | "import-declaration": { 125 | "comment": "import-declaration", 126 | "captures": { 127 | "1": { 128 | "name": "keyword.other.import.swift" 129 | }, 130 | "3": { 131 | "name": "support.type.module.import.swift" 132 | }, 133 | "2": { 134 | "name": "storage.modifier.swift" 135 | } 136 | }, 137 | "name": "meta.import.swift", 138 | "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|[/=\\-+!*%<>&|\\^~.]+))*)" 139 | }, 140 | "string-literal": { 141 | "endCaptures": { 142 | "0": { 143 | "name": "string.quoted.double.swift" 144 | } 145 | }, 146 | "beginCaptures": { 147 | "0": { 148 | "name": "string.quoted.double.swift" 149 | } 150 | }, 151 | "patterns": [ 152 | { 153 | "name": "constant.character.escape.swift", 154 | "match": "\\\\([0tnr\\\"\\'\\\\]|x\\h{2}|u\\h{4}|U\\h{8})" 155 | }, 156 | { 157 | "endCaptures": { 158 | "1": { 159 | "name": "support.punctuation.expression.end.swift" 160 | } 161 | }, 162 | "beginCaptures": { 163 | "1": { 164 | "name": "support.punctuation.expression.begin.swift" 165 | } 166 | }, 167 | "contentName": "meta.expression.swift", 168 | "patterns": [ 169 | { 170 | "include": "source.swift" 171 | } 172 | ], 173 | "begin": "(\\\\\\()", 174 | "end": "(\\))" 175 | }, 176 | { 177 | "name": "invalid.illegal.swift", 178 | "match": "(\\\"|\\\\)" 179 | }, 180 | { 181 | "name": "string.quoted.double.swift", 182 | "match": "(.)" 183 | } 184 | ], 185 | "begin": "\\\"", 186 | "end": "\\\"", 187 | "name": "meta.literal.string.swift" 188 | }, 189 | "nil-literal": { 190 | "comment": "nil-literal", 191 | "name": "constant.nil.swift", 192 | "match": "\\bnil\\b" 193 | }, 194 | "bitwise-operator": { 195 | "name": "keyword.operator.bitwise.swift", 196 | "match": "(?&|\\^~.])(&|\\||\\^|<<|>>)(?![/=\\-+!*%<>&|\\^~.])" 197 | }, 198 | "attribute": { 199 | "comment": "attribute", 200 | "patterns": [ 201 | { 202 | "endCaptures": { 203 | "0": { 204 | "name": "punctuation.definition.attribute-arguments.end.swift" 205 | } 206 | }, 207 | "beginCaptures": { 208 | "1": { 209 | "name": "storage.modifier.attribute.swift" 210 | }, 211 | "3": { 212 | "name": "punctuation.definition.attribute-arguments.begin.swift" 213 | }, 214 | "2": { 215 | "name": "punctuation.definition.attribute.swift" 216 | } 217 | }, 218 | "contentName": "meta.attribute.arguments.swift", 219 | "patterns": [ 220 | { 221 | "include": "$self" 222 | } 223 | ], 224 | "begin": "((@)(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B))(\\()", 225 | "end": "\\)" 226 | }, 227 | { 228 | "captures": { 229 | "1": { 230 | "name": "storage.modifier.attribute.swift" 231 | }, 232 | "2": { 233 | "name": "punctuation.definition.attribute.swift" 234 | } 235 | }, 236 | "match": "((@)(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B))" 237 | } 238 | ], 239 | "name": "meta.attribute.swift" 240 | }, 241 | "loop-statement-keyword": { 242 | "comment": "loop-statement", 243 | "name": "keyword.control.loop.swift", 244 | "match": "\\b(while|repeat|for|in)\\b" 245 | }, 246 | "dictionary-type": { 247 | "endCaptures": { 248 | "1": { 249 | "name": "punctuation.dictionary.end.swift" 250 | } 251 | }, 252 | "beginCaptures": { 253 | "1": { 254 | "name": "support.type.dictionary.swift" 255 | }, 256 | "2": { 257 | "name": "punctuation.dictionary.begin.swift" 258 | } 259 | }, 260 | "patterns": [ 261 | { 262 | "include": "$self" 263 | } 264 | ], 265 | "begin": "\\b(Dictionary)(<)", 266 | "end": "(>)", 267 | "name": "meta.dictionary.swift" 268 | }, 269 | "parameter-clause": { 270 | "endCaptures": { 271 | "1": { 272 | "name": "punctuation.definition.function-arguments.end.swift" 273 | } 274 | }, 275 | "beginCaptures": { 276 | "1": { 277 | "name": "punctuation.definition.function-arguments.begin.swift" 278 | } 279 | }, 280 | "comment": "parameter-clause", 281 | "patterns": [ 282 | { 283 | "include": "$self" 284 | } 285 | ], 286 | "begin": "(\\()", 287 | "end": "(\\))", 288 | "name": "meta.parameter-clause.swift" 289 | }, 290 | "comment": { 291 | "comment": "All comment types", 292 | "patterns": [ 293 | { 294 | "include": "#documentation-comment" 295 | }, 296 | { 297 | "include": "#block-comment" 298 | }, 299 | { 300 | "include": "#in-line-comment" 301 | } 302 | ] 303 | }, 304 | "special-literal": { 305 | "name": "keyword.other.literal.swift", 306 | "match": "\\b__(FILE|LINE|COLUMN|FUNCTION)__\\b" 307 | }, 308 | "array-type": { 309 | "endCaptures": { 310 | "1": { 311 | "name": "punctuation.array.end.swift" 312 | } 313 | }, 314 | "beginCaptures": { 315 | "1": { 316 | "name": "support.type.array.swift" 317 | }, 318 | "2": { 319 | "name": "punctuation.array.begin.swift" 320 | } 321 | }, 322 | "patterns": [ 323 | { 324 | "include": "$self" 325 | } 326 | ], 327 | "begin": "\\b(Array)(<)", 328 | "end": "(>)", 329 | "name": "meta.array.swift" 330 | }, 331 | "integer-type": { 332 | "comment": "Int types", 333 | "name": "support.type.swift", 334 | "match": "\\bU?Int(8|16|32|64)?\\b" 335 | }, 336 | "function-declaration": { 337 | "beginCaptures": { 338 | "1": { 339 | "name": "storage.type.function.swift" 340 | }, 341 | "2": { 342 | "name": "entity.type.function.swift" 343 | } 344 | }, 345 | "comment": "function-declaration", 346 | "patterns": [ 347 | { 348 | "include": "#generic-parameter-clause" 349 | }, 350 | { 351 | "include": "#parameter-clause" 352 | }, 353 | { 354 | "include": "#function-result" 355 | }, 356 | { 357 | "include": "#function-body" 358 | } 359 | ], 360 | "begin": "\\b(func)\\s+(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B|[/=\\-+!*%<>&|\\^~.]+)\\s*(?=\\(|<)", 361 | "end": "(?<=\\})", 362 | "name": "meta.function-declaration.swift" 363 | }, 364 | "code-block": { 365 | "endCaptures": { 366 | "1": { 367 | "name": "punctuation.definition.code-block.end.swift" 368 | } 369 | }, 370 | "beginCaptures": { 371 | "1": { 372 | "name": "punctuation.definition.code-block.begin.swift" 373 | } 374 | }, 375 | "comment": "code-block", 376 | "patterns": [ 377 | { 378 | "include": "$self" 379 | } 380 | ], 381 | "begin": "(\\{)", 382 | "end": "(\\})" 383 | }, 384 | "identifier": { 385 | "comment": "identifier", 386 | "name": "meta.identifier.swift", 387 | "match": "(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B)" 388 | }, 389 | "ternary-operator": { 390 | "name": "keyword.operator.ternary.swift", 391 | "match": "(?<=[\\s(\\[{,;:])(\\?|:)(?=[\\s)\\]},;:])" 392 | }, 393 | "function-body": { 394 | "comment": "function-body", 395 | "patterns": [ 396 | { 397 | "include": "#code-block" 398 | } 399 | ], 400 | "name": "meta.function-body.swift" 401 | }, 402 | "control-transfer-statement-keyword": { 403 | "comment": "control-transfer-statement", 404 | "name": "keyword.control.transfer.swift", 405 | "match": "\\b(continue|break|fallthrough|return)\\b" 406 | }, 407 | "boolean": { 408 | "name": "keyword.constant.boolean.swift", 409 | "match": "\\b(true|false)\\b" 410 | }, 411 | "optional-type": { 412 | "endCaptures": { 413 | "1": { 414 | "name": "punctuation.optional.end.swift" 415 | } 416 | }, 417 | "match": "\\b(Optional)(<)", 418 | "beginCaptures": { 419 | "1": { 420 | "name": "support.type.optional.swift" 421 | }, 422 | "2": { 423 | "name": "punctuation.optional.begin.swift" 424 | } 425 | }, 426 | "patterns": [ 427 | { 428 | "include": "$self" 429 | } 430 | ], 431 | "end": "(>)", 432 | "name": "meta.optional.swift" 433 | }, 434 | "arithmetic-operator": { 435 | "name": "keyword.operator.arithmetic.swift", 436 | "match": "(?&|\\^~.])(\\+|\\-|\\*|\\/)(?![/=\\-+!*%<>&|\\^~.])" 437 | }, 438 | "logical-operator": { 439 | "name": "keyword.operator.logical.swift", 440 | "match": "(?&|\\^~.])(!|&&|\\|\\|)(?![/=\\-+!*%<>&|\\^~.])" 441 | }, 442 | "declaration": { 443 | "comment": "declaration", 444 | "patterns": [ 445 | { 446 | "include": "#import-declaration" 447 | }, 448 | { 449 | "include": "#function-declaration" 450 | } 451 | ], 452 | "name": "meta.declaration.swift" 453 | }, 454 | "increment-decrement-operator": { 455 | "name": "keyword.operator.increment-or-decrement.swift", 456 | "match": "(?&|\\^~.])(\\+\\+|\\-\\-)(?![/=\\-+!*%<>&|\\^~.])" 457 | }, 458 | "access-level-modifier": { 459 | "comment": "access-level-modifier", 460 | "name": "keyword.other.access-level-modifier.swift", 461 | "match": "\\b(open|public|internal|fileprivate|private)\\b(?:\\(set\\))?" 462 | }, 463 | "branch-statement-keyword": { 464 | "patterns": [ 465 | { 466 | "include": "#if-statement-keyword" 467 | }, 468 | { 469 | "include": "#switch-statement-keyword" 470 | } 471 | ], 472 | "name": "keyword.control.branch.swift" 473 | }, 474 | "declaration-modifier": { 475 | "comment": "declaration-modifier", 476 | "name": "keyword.other.declaration-modifier.swift", 477 | "match": "\\b(class|convenience|dynamic|final|lazy|(non)?mutating|optional|override|required|static|unowned((un)?safe)?|weak)\\b" 478 | }, 479 | "keyword": { 480 | "patterns": [ 481 | { 482 | "include": "#branch-statement-keyword" 483 | }, 484 | { 485 | "include": "#control-transfer-statement-keyword" 486 | }, 487 | { 488 | "include": "#loop-statement-keyword" 489 | }, 490 | { 491 | "include": "#catch-statement-keyword" 492 | }, 493 | { 494 | "include": "#operator-declaration-modifier" 495 | }, 496 | { 497 | "include": "#declaration-modifier" 498 | }, 499 | { 500 | "include": "#access-level-modifier" 501 | }, 502 | { 503 | "comment": "declaration keyword", 504 | "name": "keyword.declaration.swift", 505 | "match": "\\b(class|deinit|enum|extension|func|import|init|let|protocol|static|struct|subscript|typealias|var|throws|rethrows)\\b" 506 | }, 507 | { 508 | "comment": "statement keyword", 509 | "name": "keyword.statement.swift", 510 | "match": "\\b(break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|repeat|catch|guard|defer|try|throw)\\b" 511 | }, 512 | { 513 | "comment": "expression and type keyword", 514 | "name": "keyword.other.statement.swift", 515 | "match": "\\b(as|dynamicType|is|new|super|self|Self|Type)\\b" 516 | }, 517 | { 518 | "comment": "other keyword", 519 | "name": "keyword.other.swift", 520 | "match": "\\b(associativity|didSet|get|infix|inout|left|mutating|none|nonmutating|operator|override|postfix|precedence|prefix|right|set|unowned((un)?safe)?|weak|willSet)\\b" 521 | } 522 | ] 523 | }, 524 | "catch-statement-keyword": { 525 | "comment": "catch-statement", 526 | "name": "kewyord.control.catch.swift", 527 | "match": "\\b(catch|do)\\b" 528 | }, 529 | "generic-parameter-clause": { 530 | "endCaptures": { 531 | "1": { 532 | "name": "punctuation.definition.generic-parameter-clause.end.swift" 533 | } 534 | }, 535 | "beginCaptures": { 536 | "1": { 537 | "name": "punctuation.definition.generic-parameter-clause.begin.swift" 538 | } 539 | }, 540 | "comment": "generic-parameter-clause", 541 | "patterns": [ 542 | { 543 | "include": "$self" 544 | } 545 | ], 546 | "begin": "(<)", 547 | "end": "(>)", 548 | "name": "meta.generic-parameter-clause.swift" 549 | }, 550 | "comparative-operator": { 551 | "name": "keyword.operator.comparative.swift", 552 | "match": "(?&|\\^~.])((=|!)==?|(<|>)=?|~=)(?![/=\\-+!*%<>&|\\^~.])" 553 | }, 554 | "literal": { 555 | "patterns": [ 556 | { 557 | "include": "#integer-literal" 558 | }, 559 | { 560 | "include": "#floating-point-literal" 561 | }, 562 | { 563 | "include": "#nil-literal" 564 | }, 565 | { 566 | "include": "#string-literal" 567 | }, 568 | { 569 | "include": "#special-literal" 570 | } 571 | ] 572 | }, 573 | "in-line-comment": { 574 | "comment": "In-line comment", 575 | "captures": { 576 | "1": { 577 | "name": "punctuation.definition.comment.line.double-slash.swift" 578 | } 579 | }, 580 | "name": "comment.line.double-slash.swift", 581 | "match": "(//).*" 582 | }, 583 | "storage-type": { 584 | "name": "storage.type.swift", 585 | "match": "\\b(var|func|let|class|enum|struct|protocol|extension|typealias)\\b" 586 | }, 587 | "primitive-type": { 588 | "comment": "Primitive types", 589 | "name": "support.type.swift", 590 | "match": "\\b(Int|Float|Double|String|Bool|Character|Void)\\b" 591 | }, 592 | "shebang-line": { 593 | "comment": "Shebang line", 594 | "captures": { 595 | "1": { 596 | "name": "punctuation.definition.comment.line.shebang.swift" 597 | } 598 | }, 599 | "name": "comment.line.shebang.swift", 600 | "match": "^(#!).*$" 601 | }, 602 | "function-result": { 603 | "beginCaptures": { 604 | "1": { 605 | "name": "keyword.operator.function-result.swift" 606 | } 607 | }, 608 | "comment": "function-result", 609 | "patterns": [ 610 | { 611 | "include": "#type" 612 | } 613 | ], 614 | "begin": "(?&|\\^~.])(\\->)(?![/=\\-+!*%<>&|\\^~.])\\s*", 615 | "end": "\\s*(?=\\{)", 616 | "name": "meta.function-result.swift" 617 | }, 618 | "floating-point-literal": { 619 | "patterns": [ 620 | { 621 | "comment": "floating-point-literal -> (decimal-literal)(decimal-fraction)?(decimal-exponent)?", 622 | "match": "\\b([0-9][0-9_]*)(\\.([0-9][0-9_]*))?([eE][+\\-]?([0-9][0-9_]*))?\\b" 623 | }, 624 | { 625 | "comment": "floating-point-literal -> (hexadecimal-literal)(hexadecimal-fraction)?(hexadecimal-exponent)", 626 | "match": "\\b(0x\\h[\\h_]*)(\\.(0x\\h[\\h_]*))?([pP][+\\-]?(0x\\h[\\h_]*))\\b" 627 | } 628 | ], 629 | "name": "constant.numeric.floating-point.swift" 630 | }, 631 | "collection-type": { 632 | "comment": "Collection types", 633 | "patterns": [ 634 | { 635 | "include": "#array-type" 636 | }, 637 | { 638 | "include": "#dictionary-type" 639 | }, 640 | { 641 | "name": "support.type.swift", 642 | "match": "\\b(Array|Dictionary)\\b" 643 | } 644 | ] 645 | }, 646 | "assignment-operator": { 647 | "name": "keyword.operator.assignment.swift", 648 | "match": "(?&|\\^~.])(\\+|\\-|\\*|\\/|%|<<|>>|&|\\^|\\||&&|\\|\\|)?=(?![/=\\-+!*%<>&|\\^~.])" 649 | }, 650 | "block-comment": { 651 | "endCaptures": { 652 | "0": { 653 | "name": "punctuation.definition.comment.block.end.swift" 654 | } 655 | }, 656 | "beginCaptures": { 657 | "0": { 658 | "name": "punctuation.definition.comment.block.begin.swift" 659 | } 660 | }, 661 | "comment": "Block comment", 662 | "begin": "/\\*", 663 | "end": "\\*/", 664 | "name": "comment.block.swift" 665 | }, 666 | "switch-statement-keyword": { 667 | "comment": "switch-statement", 668 | "name": "keyword.control.switch.swift", 669 | "match": "\\b(switch|case|default|where)\\b" 670 | }, 671 | "remainder-operator": { 672 | "name": "keyword.operator.remainder.swift", 673 | "match": "(?&|\\^~.])\\%(?![/=\\-+!*%<>&|\\^~.])" 674 | }, 675 | "documentation-comment": { 676 | "endCaptures": { 677 | "0": { 678 | "name": "punctuation.definition.comment.block.documentation.end.swift" 679 | } 680 | }, 681 | "beginCaptures": { 682 | "0": { 683 | "name": "punctuation.definition.comment.block.documentation.begin.swift" 684 | } 685 | }, 686 | "comment": "Documentation comment", 687 | "begin": "/\\*\\*", 688 | "end": "\\*/", 689 | "name": "comment.block.documentation.swift" 690 | }, 691 | "integer-literal": { 692 | "patterns": [ 693 | { 694 | "comment": "binary-literal", 695 | "name": "constant.numeric.integer.binary.swift", 696 | "match": "(\\B\\-|\\b)(0b[01][01_]*)\\b" 697 | }, 698 | { 699 | "comment": "octal-literal", 700 | "name": "constant.numeric.integer.octal.swift", 701 | "match": "(\\B\\-|\\b)(0o[0-7][0-7_]*)\\b" 702 | }, 703 | { 704 | "comment": "decimal-literal", 705 | "name": "constant.numeric.integer.decimal.swift", 706 | "match": "(\\B\\-|\\b)([0-9][0-9_]*)\\b" 707 | }, 708 | { 709 | "comment": "hexadecimal-literal", 710 | "name": "constant.numeric.integer.hexadecimal.swift", 711 | "match": "(\\B\\-|\\b)(0x\\h[\\h_]*)\\b" 712 | } 713 | ], 714 | "name": "constant.numeric.integer.swift" 715 | }, 716 | "range-operator": { 717 | "name": "keyword.operator.range.swift", 718 | "match": "(?&|\\^~.])\\.\\.(?:\\.)?(?![/=\\-+!*%<>&|\\^~.])" 719 | } 720 | }, 721 | "author": "Matt Alexander - matt@queg.net", 722 | "keyEquivalent": "^~S", 723 | "fileTypes": [ 724 | "swift" 725 | ], 726 | "patterns": [ 727 | { 728 | "include": "#shebang-line" 729 | }, 730 | { 731 | "include": "#comment" 732 | }, 733 | { 734 | "include": "#attribute" 735 | }, 736 | { 737 | "include": "#literal" 738 | }, 739 | { 740 | "include": "#operator" 741 | }, 742 | { 743 | "include": "#declaration" 744 | }, 745 | { 746 | "include": "#storage-type" 747 | }, 748 | { 749 | "include": "#keyword" 750 | }, 751 | { 752 | "include": "#type" 753 | }, 754 | { 755 | "include": "#boolean" 756 | } 757 | ] 758 | } 759 | -------------------------------------------------------------------------------- /Syntaxes/Swift.tmLanguage: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | author 6 | Matt Alexander - matt@queg.net 7 | fileTypes 8 | 9 | swift 10 | 11 | firstLineMatch 12 | ^#!/.*\bswift 13 | keyEquivalent 14 | ^~S 15 | name 16 | Swift 17 | patterns 18 | 19 | 20 | include 21 | #shebang-line 22 | 23 | 24 | include 25 | #comment 26 | 27 | 28 | include 29 | #attribute 30 | 31 | 32 | include 33 | #literal 34 | 35 | 36 | include 37 | #operator 38 | 39 | 40 | include 41 | #declaration 42 | 43 | 44 | include 45 | #storage-type 46 | 47 | 48 | include 49 | #keyword 50 | 51 | 52 | include 53 | #type 54 | 55 | 56 | include 57 | #boolean 58 | 59 | 60 | repository 61 | 62 | access-level-modifier 63 | 64 | comment 65 | access-level-modifier 66 | match 67 | \b(open|public|internal|fileprivate|private)\b(?:\(set\))? 68 | name 69 | keyword.other.access-level-modifier.swift 70 | 71 | arithmetic-operator 72 | 73 | match 74 | (?<![/=\-+!*%<>&|\^~.])(\+|\-|\*|\/)(?![/=\-+!*%<>&|\^~.]) 75 | name 76 | keyword.operator.arithmetic.swift 77 | 78 | array-type 79 | 80 | begin 81 | \b(Array)(<) 82 | beginCaptures 83 | 84 | 1 85 | 86 | name 87 | support.type.array.swift 88 | 89 | 2 90 | 91 | name 92 | punctuation.array.begin.swift 93 | 94 | 95 | end 96 | (>) 97 | endCaptures 98 | 99 | 1 100 | 101 | name 102 | punctuation.array.end.swift 103 | 104 | 105 | name 106 | meta.array.swift 107 | patterns 108 | 109 | 110 | include 111 | $self 112 | 113 | 114 | 115 | assignment-operator 116 | 117 | match 118 | (?<![/=\-+!*%<>&|\^~.])(\+|\-|\*|\/|%|<<|>>|&|\^|\||&&|\|\|)?=(?![/=\-+!*%<>&|\^~.]) 119 | name 120 | keyword.operator.assignment.swift 121 | 122 | attribute 123 | 124 | comment 125 | attribute 126 | name 127 | meta.attribute.swift 128 | patterns 129 | 130 | 131 | begin 132 | ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B))(\() 133 | beginCaptures 134 | 135 | 1 136 | 137 | name 138 | storage.modifier.attribute.swift 139 | 140 | 2 141 | 142 | name 143 | punctuation.definition.attribute.swift 144 | 145 | 3 146 | 147 | name 148 | punctuation.definition.attribute-arguments.begin.swift 149 | 150 | 151 | contentName 152 | meta.attribute.arguments.swift 153 | end 154 | \) 155 | endCaptures 156 | 157 | 0 158 | 159 | name 160 | punctuation.definition.attribute-arguments.end.swift 161 | 162 | 163 | patterns 164 | 165 | 166 | include 167 | $self 168 | 169 | 170 | 171 | 172 | captures 173 | 174 | 1 175 | 176 | name 177 | storage.modifier.attribute.swift 178 | 179 | 2 180 | 181 | name 182 | punctuation.definition.attribute.swift 183 | 184 | 185 | match 186 | ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B)) 187 | 188 | 189 | 190 | bitwise-operator 191 | 192 | match 193 | (?<![/=\-+!*%<>&|\^~.])(&|\||\^|<<|>>)(?![/=\-+!*%<>&|\^~.]) 194 | name 195 | keyword.operator.bitwise.swift 196 | 197 | block-comment 198 | 199 | begin 200 | /\* 201 | beginCaptures 202 | 203 | 0 204 | 205 | name 206 | punctuation.definition.comment.block.begin.swift 207 | 208 | 209 | comment 210 | Block comment 211 | end 212 | \*/ 213 | endCaptures 214 | 215 | 0 216 | 217 | name 218 | punctuation.definition.comment.block.end.swift 219 | 220 | 221 | name 222 | comment.block.swift 223 | 224 | boolean 225 | 226 | match 227 | \b(true|false)\b 228 | name 229 | keyword.constant.boolean.swift 230 | 231 | branch-statement-keyword 232 | 233 | name 234 | keyword.control.branch.swift 235 | patterns 236 | 237 | 238 | include 239 | #if-statement-keyword 240 | 241 | 242 | include 243 | #switch-statement-keyword 244 | 245 | 246 | 247 | catch-statement-keyword 248 | 249 | comment 250 | catch-statement 251 | match 252 | \b(catch|do)\b 253 | name 254 | kewyord.control.catch.swift 255 | 256 | code-block 257 | 258 | begin 259 | (\{) 260 | beginCaptures 261 | 262 | 1 263 | 264 | name 265 | punctuation.definition.code-block.begin.swift 266 | 267 | 268 | comment 269 | code-block 270 | end 271 | (\}) 272 | endCaptures 273 | 274 | 1 275 | 276 | name 277 | punctuation.definition.code-block.end.swift 278 | 279 | 280 | patterns 281 | 282 | 283 | include 284 | $self 285 | 286 | 287 | 288 | collection-type 289 | 290 | comment 291 | Collection types 292 | patterns 293 | 294 | 295 | include 296 | #array-type 297 | 298 | 299 | include 300 | #dictionary-type 301 | 302 | 303 | match 304 | \b(Array|Dictionary)\b 305 | name 306 | support.type.swift 307 | 308 | 309 | 310 | comment 311 | 312 | comment 313 | All comment types 314 | patterns 315 | 316 | 317 | include 318 | #documentation-comment 319 | 320 | 321 | include 322 | #block-comment 323 | 324 | 325 | include 326 | #in-line-comment 327 | 328 | 329 | 330 | comparative-operator 331 | 332 | match 333 | (?<![/=\-+!*%<>&|\^~.])((=|!)==?|(<|>)=?|~=)(?![/=\-+!*%<>&|\^~.]) 334 | name 335 | keyword.operator.comparative.swift 336 | 337 | control-transfer-statement-keyword 338 | 339 | comment 340 | control-transfer-statement 341 | match 342 | \b(continue|break|fallthrough|return)\b 343 | name 344 | keyword.control.transfer.swift 345 | 346 | custom-operator 347 | 348 | patterns 349 | 350 | 351 | match 352 | (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:]) 353 | name 354 | keyword.operator.custom.prefix.unary.swift 355 | 356 | 357 | match 358 | (?<![\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:\.]) 359 | name 360 | keyword.operator.custom.postfix.unary.swift 361 | 362 | 363 | match 364 | (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?=[\s)\]},;:]) 365 | name 366 | keyword.operator.custom.binary.swift 367 | 368 | 369 | 370 | declaration 371 | 372 | comment 373 | declaration 374 | name 375 | meta.declaration.swift 376 | patterns 377 | 378 | 379 | include 380 | #import-declaration 381 | 382 | 383 | include 384 | #function-declaration 385 | 386 | 387 | 388 | declaration-modifier 389 | 390 | comment 391 | declaration-modifier 392 | match 393 | \b(class|convenience|dynamic|final|lazy|(non)?mutating|optional|override|required|static|unowned((un)?safe)?|weak)\b 394 | name 395 | keyword.other.declaration-modifier.swift 396 | 397 | dictionary-type 398 | 399 | begin 400 | \b(Dictionary)(<) 401 | beginCaptures 402 | 403 | 1 404 | 405 | name 406 | support.type.dictionary.swift 407 | 408 | 2 409 | 410 | name 411 | punctuation.dictionary.begin.swift 412 | 413 | 414 | end 415 | (>) 416 | endCaptures 417 | 418 | 1 419 | 420 | name 421 | punctuation.dictionary.end.swift 422 | 423 | 424 | name 425 | meta.dictionary.swift 426 | patterns 427 | 428 | 429 | include 430 | $self 431 | 432 | 433 | 434 | documentation-comment 435 | 436 | begin 437 | /\*\* 438 | beginCaptures 439 | 440 | 0 441 | 442 | name 443 | punctuation.definition.comment.block.documentation.begin.swift 444 | 445 | 446 | comment 447 | Documentation comment 448 | end 449 | \*/ 450 | endCaptures 451 | 452 | 0 453 | 454 | name 455 | punctuation.definition.comment.block.documentation.end.swift 456 | 457 | 458 | name 459 | comment.block.documentation.swift 460 | 461 | floating-point-literal 462 | 463 | name 464 | constant.numeric.floating-point.swift 465 | patterns 466 | 467 | 468 | comment 469 | floating-point-literal -> (decimal-literal)(decimal-fraction)?(decimal-exponent)? 470 | match 471 | \b([0-9][0-9_]*)(\.([0-9][0-9_]*))?([eE][+\-]?([0-9][0-9_]*))?\b 472 | 473 | 474 | comment 475 | floating-point-literal -> (hexadecimal-literal)(hexadecimal-fraction)?(hexadecimal-exponent) 476 | match 477 | \b(0x\h[\h_]*)(\.(0x\h[\h_]*))?([pP][+\-]?(0x\h[\h_]*))\b 478 | 479 | 480 | 481 | function-body 482 | 483 | comment 484 | function-body 485 | name 486 | meta.function-body.swift 487 | patterns 488 | 489 | 490 | include 491 | #code-block 492 | 493 | 494 | 495 | function-declaration 496 | 497 | begin 498 | \b(func)\s+(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B|[/=\-+!*%<>&|\^~.]+)\s*(?=\(|<) 499 | beginCaptures 500 | 501 | 1 502 | 503 | name 504 | storage.type.function.swift 505 | 506 | 2 507 | 508 | name 509 | entity.type.function.swift 510 | 511 | 512 | comment 513 | function-declaration 514 | end 515 | (?<=\}) 516 | name 517 | meta.function-declaration.swift 518 | patterns 519 | 520 | 521 | include 522 | #generic-parameter-clause 523 | 524 | 525 | include 526 | #parameter-clause 527 | 528 | 529 | include 530 | #function-result 531 | 532 | 533 | include 534 | #function-body 535 | 536 | 537 | 538 | function-result 539 | 540 | begin 541 | (?<![/=\-+!*%<>&|\^~.])(\->)(?![/=\-+!*%<>&|\^~.])\s* 542 | beginCaptures 543 | 544 | 1 545 | 546 | name 547 | keyword.operator.function-result.swift 548 | 549 | 550 | comment 551 | function-result 552 | end 553 | \s*(?=\{) 554 | name 555 | meta.function-result.swift 556 | patterns 557 | 558 | 559 | include 560 | #type 561 | 562 | 563 | 564 | generic-parameter-clause 565 | 566 | begin 567 | (<) 568 | beginCaptures 569 | 570 | 1 571 | 572 | name 573 | punctuation.definition.generic-parameter-clause.begin.swift 574 | 575 | 576 | comment 577 | generic-parameter-clause 578 | end 579 | (>) 580 | endCaptures 581 | 582 | 1 583 | 584 | name 585 | punctuation.definition.generic-parameter-clause.end.swift 586 | 587 | 588 | name 589 | meta.generic-parameter-clause.swift 590 | patterns 591 | 592 | 593 | include 594 | $self 595 | 596 | 597 | 598 | identifier 599 | 600 | comment 601 | identifier 602 | match 603 | (\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B) 604 | name 605 | meta.identifier.swift 606 | 607 | if-statement-keyword 608 | 609 | comment 610 | if-statement 611 | match 612 | \b(if|else)\b 613 | name 614 | keyword.control.if.swift 615 | 616 | import-declaration 617 | 618 | captures 619 | 620 | 1 621 | 622 | name 623 | keyword.other.import.swift 624 | 625 | 2 626 | 627 | name 628 | storage.modifier.swift 629 | 630 | 3 631 | 632 | name 633 | support.type.module.import.swift 634 | 635 | 636 | comment 637 | import-declaration 638 | match 639 | \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|[/=\-+!*%<>&|\^~.]+))*) 640 | name 641 | meta.import.swift 642 | 643 | in-line-comment 644 | 645 | captures 646 | 647 | 1 648 | 649 | name 650 | punctuation.definition.comment.line.double-slash.swift 651 | 652 | 653 | comment 654 | In-line comment 655 | match 656 | (//).* 657 | name 658 | comment.line.double-slash.swift 659 | 660 | increment-decrement-operator 661 | 662 | match 663 | (?<![/=\-+!*%<>&|\^~.])(\+\+|\-\-)(?![/=\-+!*%<>&|\^~.]) 664 | name 665 | keyword.operator.increment-or-decrement.swift 666 | 667 | integer-literal 668 | 669 | name 670 | constant.numeric.integer.swift 671 | patterns 672 | 673 | 674 | comment 675 | binary-literal 676 | match 677 | (\B\-|\b)(0b[01][01_]*)\b 678 | name 679 | constant.numeric.integer.binary.swift 680 | 681 | 682 | comment 683 | octal-literal 684 | match 685 | (\B\-|\b)(0o[0-7][0-7_]*)\b 686 | name 687 | constant.numeric.integer.octal.swift 688 | 689 | 690 | comment 691 | decimal-literal 692 | match 693 | (\B\-|\b)([0-9][0-9_]*)\b 694 | name 695 | constant.numeric.integer.decimal.swift 696 | 697 | 698 | comment 699 | hexadecimal-literal 700 | match 701 | (\B\-|\b)(0x\h[\h_]*)\b 702 | name 703 | constant.numeric.integer.hexadecimal.swift 704 | 705 | 706 | 707 | integer-type 708 | 709 | comment 710 | Int types 711 | match 712 | \bU?Int(8|16|32|64)?\b 713 | name 714 | support.type.swift 715 | 716 | keyword 717 | 718 | patterns 719 | 720 | 721 | include 722 | #branch-statement-keyword 723 | 724 | 725 | include 726 | #control-transfer-statement-keyword 727 | 728 | 729 | include 730 | #loop-statement-keyword 731 | 732 | 733 | include 734 | #catch-statement-keyword 735 | 736 | 737 | include 738 | #operator-declaration-modifier 739 | 740 | 741 | include 742 | #declaration-modifier 743 | 744 | 745 | include 746 | #access-level-modifier 747 | 748 | 749 | comment 750 | declaration keyword 751 | match 752 | \b(class|deinit|enum|extension|func|import|init|let|protocol|static|struct|subscript|typealias|var|throws|rethrows)\b 753 | name 754 | keyword.declaration.swift 755 | 756 | 757 | comment 758 | statement keyword 759 | match 760 | \b(break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|repeat|catch|guard|defer|try|throw)\b 761 | name 762 | keyword.statement.swift 763 | 764 | 765 | comment 766 | expression and type keyword 767 | match 768 | \b(as|dynamicType|is|new|super|self|Self|Type)\b 769 | name 770 | keyword.other.statement.swift 771 | 772 | 773 | comment 774 | other keyword 775 | match 776 | \b(associativity|didSet|get|infix|inout|left|mutating|none|nonmutating|operator|override|postfix|precedence|prefix|right|set|unowned((un)?safe)?|weak|willSet)\b 777 | name 778 | keyword.other.swift 779 | 780 | 781 | 782 | literal 783 | 784 | patterns 785 | 786 | 787 | include 788 | #integer-literal 789 | 790 | 791 | include 792 | #floating-point-literal 793 | 794 | 795 | include 796 | #nil-literal 797 | 798 | 799 | include 800 | #string-literal 801 | 802 | 803 | include 804 | #special-literal 805 | 806 | 807 | 808 | logical-operator 809 | 810 | match 811 | (?<![/=\-+!*%<>&|\^~.])(!|&&|\|\|)(?![/=\-+!*%<>&|\^~.]) 812 | name 813 | keyword.operator.logical.swift 814 | 815 | loop-statement-keyword 816 | 817 | comment 818 | loop-statement 819 | match 820 | \b(while|repeat|for|in)\b 821 | name 822 | keyword.control.loop.swift 823 | 824 | nil-literal 825 | 826 | comment 827 | nil-literal 828 | match 829 | \bnil\b 830 | name 831 | constant.nil.swift 832 | 833 | operator 834 | 835 | patterns 836 | 837 | 838 | include 839 | #comparative-operator 840 | 841 | 842 | include 843 | #assignment-operator 844 | 845 | 846 | include 847 | #logical-operator 848 | 849 | 850 | include 851 | #remainder-operator 852 | 853 | 854 | include 855 | #increment-decrement-operator 856 | 857 | 858 | include 859 | #overflow-operator 860 | 861 | 862 | include 863 | #range-operator 864 | 865 | 866 | include 867 | #bitwise-operator 868 | 869 | 870 | include 871 | #arithmetic-operator 872 | 873 | 874 | include 875 | #ternary-operator 876 | 877 | 878 | include 879 | #type-casting-operator 880 | 881 | 882 | include 883 | #custom-operator 884 | 885 | 886 | 887 | operator-declaration-modifier 888 | 889 | comment 890 | operator-declaration 891 | match 892 | \b(operator|prefix|infix|postfix)\b 893 | name 894 | keyword.other.operator.swift 895 | 896 | optional-type 897 | 898 | beginCaptures 899 | 900 | 1 901 | 902 | name 903 | support.type.optional.swift 904 | 905 | 2 906 | 907 | name 908 | punctuation.optional.begin.swift 909 | 910 | 911 | end 912 | (>) 913 | endCaptures 914 | 915 | 1 916 | 917 | name 918 | punctuation.optional.end.swift 919 | 920 | 921 | match 922 | \b(Optional)(<) 923 | name 924 | meta.optional.swift 925 | patterns 926 | 927 | 928 | include 929 | $self 930 | 931 | 932 | 933 | overflow-operator 934 | 935 | match 936 | (?<![/=\-+!*%<>&|\^~.])\&(\+|\-|\*|\/|%)(?![/=\-+!*%<>&|\^~.]) 937 | name 938 | keyword.operator.overflow.swift 939 | 940 | parameter-clause 941 | 942 | begin 943 | (\() 944 | beginCaptures 945 | 946 | 1 947 | 948 | name 949 | punctuation.definition.function-arguments.begin.swift 950 | 951 | 952 | comment 953 | parameter-clause 954 | end 955 | (\)) 956 | endCaptures 957 | 958 | 1 959 | 960 | name 961 | punctuation.definition.function-arguments.end.swift 962 | 963 | 964 | name 965 | meta.parameter-clause.swift 966 | patterns 967 | 968 | 969 | include 970 | $self 971 | 972 | 973 | 974 | primitive-type 975 | 976 | comment 977 | Primitive types 978 | match 979 | \b(Int|Float|Double|String|Bool|Character|Void)\b 980 | name 981 | support.type.swift 982 | 983 | protocol-composition-type 984 | 985 | beginCaptures 986 | 987 | 1 988 | 989 | name 990 | support.type.protocol.swift 991 | 992 | 2 993 | 994 | name 995 | punctuation.protocol.begin.swift 996 | 997 | 998 | end 999 | (>) 1000 | endCaptures 1001 | 1002 | 1 1003 | 1004 | name 1005 | punctuation.protocol.end.swift 1006 | 1007 | 1008 | match 1009 | \b(protocol)(<) 1010 | name 1011 | meta.protocol.swift 1012 | patterns 1013 | 1014 | 1015 | include 1016 | $self 1017 | 1018 | 1019 | 1020 | range-operator 1021 | 1022 | match 1023 | (?<![/=\-+!*%<>&|\^~.])\.\.(?:\.)?(?![/=\-+!*%<>&|\^~.]) 1024 | name 1025 | keyword.operator.range.swift 1026 | 1027 | remainder-operator 1028 | 1029 | match 1030 | (?<![/=\-+!*%<>&|\^~.])\%(?![/=\-+!*%<>&|\^~.]) 1031 | name 1032 | keyword.operator.remainder.swift 1033 | 1034 | shebang-line 1035 | 1036 | captures 1037 | 1038 | 1 1039 | 1040 | name 1041 | punctuation.definition.comment.line.shebang.swift 1042 | 1043 | 1044 | comment 1045 | Shebang line 1046 | match 1047 | ^(#!).*$ 1048 | name 1049 | comment.line.shebang.swift 1050 | 1051 | special-literal 1052 | 1053 | match 1054 | \b__(FILE|LINE|COLUMN|FUNCTION)__\b 1055 | name 1056 | keyword.other.literal.swift 1057 | 1058 | storage-type 1059 | 1060 | match 1061 | \b(var|func|let|class|enum|struct|protocol|extension|typealias)\b 1062 | name 1063 | storage.type.swift 1064 | 1065 | string-literal 1066 | 1067 | begin 1068 | \" 1069 | beginCaptures 1070 | 1071 | 0 1072 | 1073 | name 1074 | string.quoted.double.swift 1075 | 1076 | 1077 | end 1078 | \" 1079 | endCaptures 1080 | 1081 | 0 1082 | 1083 | name 1084 | string.quoted.double.swift 1085 | 1086 | 1087 | name 1088 | meta.literal.string.swift 1089 | patterns 1090 | 1091 | 1092 | match 1093 | \\([0tnr\"\'\\]|x\h{2}|u\h{4}|U\h{8}) 1094 | name 1095 | constant.character.escape.swift 1096 | 1097 | 1098 | begin 1099 | (\\\() 1100 | beginCaptures 1101 | 1102 | 1 1103 | 1104 | name 1105 | support.punctuation.expression.begin.swift 1106 | 1107 | 1108 | contentName 1109 | meta.expression.swift 1110 | end 1111 | (\)) 1112 | endCaptures 1113 | 1114 | 1 1115 | 1116 | name 1117 | support.punctuation.expression.end.swift 1118 | 1119 | 1120 | patterns 1121 | 1122 | 1123 | include 1124 | source.swift 1125 | 1126 | 1127 | 1128 | 1129 | match 1130 | (\"|\\) 1131 | name 1132 | invalid.illegal.swift 1133 | 1134 | 1135 | match 1136 | (.) 1137 | name 1138 | string.quoted.double.swift 1139 | 1140 | 1141 | 1142 | switch-statement-keyword 1143 | 1144 | comment 1145 | switch-statement 1146 | match 1147 | \b(switch|case|default|where)\b 1148 | name 1149 | keyword.control.switch.swift 1150 | 1151 | ternary-operator 1152 | 1153 | match 1154 | (?<=[\s(\[{,;:])(\?|:)(?=[\s)\]},;:]) 1155 | name 1156 | keyword.operator.ternary.swift 1157 | 1158 | type 1159 | 1160 | comment 1161 | type 1162 | patterns 1163 | 1164 | 1165 | include 1166 | #primitive-type 1167 | 1168 | 1169 | include 1170 | #integer-type 1171 | 1172 | 1173 | include 1174 | #collection-type 1175 | 1176 | 1177 | include 1178 | #optional-type 1179 | 1180 | 1181 | include 1182 | #protocol-composition-type 1183 | 1184 | 1185 | 1186 | type-casting-operator 1187 | 1188 | match 1189 | \b(is\b|as(\?\B|\b)) 1190 | name 1191 | keyword.operator.type-casting.swift 1192 | 1193 | 1194 | scopeName 1195 | source.swift 1196 | uuid 1197 | 7efa1168-97c3-4433-8dd7-15b99bf3bb53 1198 | 1199 | 1200 | --------------------------------------------------------------------------------