From d9a013de2209a07e3b9500408331ffc34731bcd3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 13 May 2019 10:10:06 -0700 Subject: [PATCH 1/2] Add Swift -Cloned from https://github.com/quiqueg/Swift-Sublime-Package.git -Removed the .git folder. (I'm thinking it doesn't make sense for it to be a submodule, it makes more sense to be a copy.) -Converted with sublime_syntax_convertor --- Packages/Swift/LICENSE | 21 + .../Swift/Preferences/Comments.tmPreferences | 36 + Packages/Swift/README.md | 41 + Packages/Swift/Snippets/Array.sublime-snippet | 7 + .../Swift/Snippets/Dictionary.sublime-snippet | 7 + .../Swift/Snippets/class-var.sublime-snippet | 8 + Packages/Swift/Snippets/class.sublime-snippet | 10 + .../Swift/Snippets/deinit.sublime-snippet | 10 + .../Swift/Snippets/didSet.sublime-snippet | 10 + .../Swift/Snippets/else-if.sublime-snippet | 10 + Packages/Swift/Snippets/else.sublime-snippet | 10 + Packages/Swift/Snippets/enum.sublime-snippet | 9 + .../Swift/Snippets/extension.sublime-snippet | 10 + Packages/Swift/Snippets/func.sublime-snippet | 9 + Packages/Swift/Snippets/get.sublime-snippet | 10 + .../Swift/Snippets/if-else.sublime-snippet | 12 + Packages/Swift/Snippets/if.sublime-snippet | 10 + Packages/Swift/Snippets/init.sublime-snippet | 10 + .../Swift/Snippets/operator.sublime-snippet | 10 + .../Swift/Snippets/protocol.sublime-snippet | 10 + Packages/Swift/Snippets/set.sublime-snippet | 10 + .../Swift/Snippets/static-var.sublime-snippet | 8 + .../Swift/Snippets/struct.sublime-snippet | 10 + .../Swift/Snippets/subscript.sublime-snippet | 10 + Packages/Swift/Snippets/swift.sublime-snippet | 9 + .../Swift/Snippets/switch.sublime-snippet | 11 + .../Swift/Snippets/typealias.sublime-snippet | 8 + .../Swift/Snippets/willSet.sublime-snippet | 10 + Packages/Swift/Syntaxes/Swift.JSON-tmLanguage | 758 +++++++++++ Packages/Swift/Syntaxes/Swift.YAML-tmLanguage | 441 ++++++ Packages/Swift/Syntaxes/Swift.sublime-syntax | 371 +++++ Packages/Swift/Syntaxes/Swift.tmLanguage | 1199 +++++++++++++++++ 32 files changed, 3105 insertions(+) create mode 100644 Packages/Swift/LICENSE create mode 100644 Packages/Swift/Preferences/Comments.tmPreferences create mode 100644 Packages/Swift/README.md create mode 100644 Packages/Swift/Snippets/Array.sublime-snippet create mode 100644 Packages/Swift/Snippets/Dictionary.sublime-snippet create mode 100644 Packages/Swift/Snippets/class-var.sublime-snippet create mode 100644 Packages/Swift/Snippets/class.sublime-snippet create mode 100644 Packages/Swift/Snippets/deinit.sublime-snippet create mode 100644 Packages/Swift/Snippets/didSet.sublime-snippet create mode 100644 Packages/Swift/Snippets/else-if.sublime-snippet create mode 100644 Packages/Swift/Snippets/else.sublime-snippet create mode 100644 Packages/Swift/Snippets/enum.sublime-snippet create mode 100644 Packages/Swift/Snippets/extension.sublime-snippet create mode 100644 Packages/Swift/Snippets/func.sublime-snippet create mode 100644 Packages/Swift/Snippets/get.sublime-snippet create mode 100644 Packages/Swift/Snippets/if-else.sublime-snippet create mode 100644 Packages/Swift/Snippets/if.sublime-snippet create mode 100644 Packages/Swift/Snippets/init.sublime-snippet create mode 100644 Packages/Swift/Snippets/operator.sublime-snippet create mode 100644 Packages/Swift/Snippets/protocol.sublime-snippet create mode 100644 Packages/Swift/Snippets/set.sublime-snippet create mode 100644 Packages/Swift/Snippets/static-var.sublime-snippet create mode 100644 Packages/Swift/Snippets/struct.sublime-snippet create mode 100644 Packages/Swift/Snippets/subscript.sublime-snippet create mode 100644 Packages/Swift/Snippets/swift.sublime-snippet create mode 100644 Packages/Swift/Snippets/switch.sublime-snippet create mode 100644 Packages/Swift/Snippets/typealias.sublime-snippet create mode 100644 Packages/Swift/Snippets/willSet.sublime-snippet create mode 100644 Packages/Swift/Syntaxes/Swift.JSON-tmLanguage create mode 100644 Packages/Swift/Syntaxes/Swift.YAML-tmLanguage create mode 100644 Packages/Swift/Syntaxes/Swift.sublime-syntax create mode 100644 Packages/Swift/Syntaxes/Swift.tmLanguage diff --git a/Packages/Swift/LICENSE b/Packages/Swift/LICENSE new file mode 100644 index 0000000..c4987dd --- /dev/null +++ b/Packages/Swift/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Matthew Alexander + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Packages/Swift/Preferences/Comments.tmPreferences b/Packages/Swift/Preferences/Comments.tmPreferences new file mode 100644 index 0000000..8c2748a --- /dev/null +++ b/Packages/Swift/Preferences/Comments.tmPreferences @@ -0,0 +1,36 @@ + + + + + name + Comments + scope + source.swift + settings + + shellVariables + + + name + TM_COMMENT_START + value + // + + + name + TM_COMMENT_START_2 + value + /* + + + name + TM_COMMENT_END_2 + value + */ + + + + uuid + e4dfd8f5-d016-4899-b491-d46e5d32b3a3 + + diff --git a/Packages/Swift/README.md b/Packages/Swift/README.md new file mode 100644 index 0000000..c656e41 --- /dev/null +++ b/Packages/Swift/README.md @@ -0,0 +1,41 @@ +# Swift-Sublime-Package + +Cloned from [Swift-Sublime-Package](https://github.com/quiqueg/Swift-Sublime-Package). + +A [Sublime Text](http://www.sublimetext.com/) package for the [Swift programming language](https://developer.apple.com/swift/) + +## Installation + +### via Package Control (Recommended) +[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). + +Once Package Control is installed, restart Sublime and follow these steps: +* Open the Command Pallette (`cmd + shift + p` on OS X / Linux or `ctrl + shift + p` on Windows) +* Type "install" and select "Package Control: Install Package" +* Type "swift" and press Enter + +All done! Package Control will automatically update the package whenever there's a new version. + +## License + +The MIT License (MIT) + +Copyright (c) 2014 Matthew Alexander + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Packages/Swift/Snippets/Array.sublime-snippet b/Packages/Swift/Snippets/Array.sublime-snippet new file mode 100644 index 0000000..7ee49a3 --- /dev/null +++ b/Packages/Swift/Snippets/Array.sublime-snippet @@ -0,0 +1,7 @@ + + +]]> + Array + source.swift + diff --git a/Packages/Swift/Snippets/Dictionary.sublime-snippet b/Packages/Swift/Snippets/Dictionary.sublime-snippet new file mode 100644 index 0000000..f5019ab --- /dev/null +++ b/Packages/Swift/Snippets/Dictionary.sublime-snippet @@ -0,0 +1,7 @@ + + +]]> + Dictionary + source.swift + diff --git a/Packages/Swift/Snippets/class-var.sublime-snippet b/Packages/Swift/Snippets/class-var.sublime-snippet new file mode 100644 index 0000000..ba1d556 --- /dev/null +++ b/Packages/Swift/Snippets/class-var.sublime-snippet @@ -0,0 +1,8 @@ + + + cv + source.swift + class var ... + diff --git a/Packages/Swift/Snippets/class.sublime-snippet b/Packages/Swift/Snippets/class.sublime-snippet new file mode 100644 index 0000000..cac1e7c --- /dev/null +++ b/Packages/Swift/Snippets/class.sublime-snippet @@ -0,0 +1,10 @@ + + + class + source.swift + class ... + diff --git a/Packages/Swift/Snippets/deinit.sublime-snippet b/Packages/Swift/Snippets/deinit.sublime-snippet new file mode 100644 index 0000000..0b26264 --- /dev/null +++ b/Packages/Swift/Snippets/deinit.sublime-snippet @@ -0,0 +1,10 @@ + + + deinit + source.swift + deinit {...} + diff --git a/Packages/Swift/Snippets/didSet.sublime-snippet b/Packages/Swift/Snippets/didSet.sublime-snippet new file mode 100644 index 0000000..2cb2538 --- /dev/null +++ b/Packages/Swift/Snippets/didSet.sublime-snippet @@ -0,0 +1,10 @@ + + + didSet + source.swift + didSet {...} + diff --git a/Packages/Swift/Snippets/else-if.sublime-snippet b/Packages/Swift/Snippets/else-if.sublime-snippet new file mode 100644 index 0000000..ed65f42 --- /dev/null +++ b/Packages/Swift/Snippets/else-if.sublime-snippet @@ -0,0 +1,10 @@ + + + elif + source.swift + else if ... + diff --git a/Packages/Swift/Snippets/else.sublime-snippet b/Packages/Swift/Snippets/else.sublime-snippet new file mode 100644 index 0000000..c0ba49a --- /dev/null +++ b/Packages/Swift/Snippets/else.sublime-snippet @@ -0,0 +1,10 @@ + + + else + source.swift + else ... + diff --git a/Packages/Swift/Snippets/enum.sublime-snippet b/Packages/Swift/Snippets/enum.sublime-snippet new file mode 100644 index 0000000..ba61463 --- /dev/null +++ b/Packages/Swift/Snippets/enum.sublime-snippet @@ -0,0 +1,9 @@ + + + enum + source.swift + diff --git a/Packages/Swift/Snippets/extension.sublime-snippet b/Packages/Swift/Snippets/extension.sublime-snippet new file mode 100644 index 0000000..75685b6 --- /dev/null +++ b/Packages/Swift/Snippets/extension.sublime-snippet @@ -0,0 +1,10 @@ + + + extension + source.swift + extension ... + diff --git a/Packages/Swift/Snippets/func.sublime-snippet b/Packages/Swift/Snippets/func.sublime-snippet new file mode 100644 index 0000000..bb6026b --- /dev/null +++ b/Packages/Swift/Snippets/func.sublime-snippet @@ -0,0 +1,9 @@ + + ${3:ReturnType} { + $4 +} +]]> + func + source.swift + diff --git a/Packages/Swift/Snippets/get.sublime-snippet b/Packages/Swift/Snippets/get.sublime-snippet new file mode 100644 index 0000000..adb89df --- /dev/null +++ b/Packages/Swift/Snippets/get.sublime-snippet @@ -0,0 +1,10 @@ + + + get + source.swift + get {...} + diff --git a/Packages/Swift/Snippets/if-else.sublime-snippet b/Packages/Swift/Snippets/if-else.sublime-snippet new file mode 100644 index 0000000..531f14c --- /dev/null +++ b/Packages/Swift/Snippets/if-else.sublime-snippet @@ -0,0 +1,12 @@ + + + ifelse + source.swift + if ... else ... + diff --git a/Packages/Swift/Snippets/if.sublime-snippet b/Packages/Swift/Snippets/if.sublime-snippet new file mode 100644 index 0000000..42990fb --- /dev/null +++ b/Packages/Swift/Snippets/if.sublime-snippet @@ -0,0 +1,10 @@ + + + if + source.swift + if ... + diff --git a/Packages/Swift/Snippets/init.sublime-snippet b/Packages/Swift/Snippets/init.sublime-snippet new file mode 100644 index 0000000..23a2a4a --- /dev/null +++ b/Packages/Swift/Snippets/init.sublime-snippet @@ -0,0 +1,10 @@ + + + init + source.swift + init(...) {...} + diff --git a/Packages/Swift/Snippets/operator.sublime-snippet b/Packages/Swift/Snippets/operator.sublime-snippet new file mode 100644 index 0000000..1c041ef --- /dev/null +++ b/Packages/Swift/Snippets/operator.sublime-snippet @@ -0,0 +1,10 @@ + + + operator + source.swift + operator ... + diff --git a/Packages/Swift/Snippets/protocol.sublime-snippet b/Packages/Swift/Snippets/protocol.sublime-snippet new file mode 100644 index 0000000..9778269 --- /dev/null +++ b/Packages/Swift/Snippets/protocol.sublime-snippet @@ -0,0 +1,10 @@ + + + protocol + source.swift + protocol ... + diff --git a/Packages/Swift/Snippets/set.sublime-snippet b/Packages/Swift/Snippets/set.sublime-snippet new file mode 100644 index 0000000..699dc6c --- /dev/null +++ b/Packages/Swift/Snippets/set.sublime-snippet @@ -0,0 +1,10 @@ + + + set + source.swift + set {...} + diff --git a/Packages/Swift/Snippets/static-var.sublime-snippet b/Packages/Swift/Snippets/static-var.sublime-snippet new file mode 100644 index 0000000..987feae --- /dev/null +++ b/Packages/Swift/Snippets/static-var.sublime-snippet @@ -0,0 +1,8 @@ + + + sv + source.swift + static var ... + diff --git a/Packages/Swift/Snippets/struct.sublime-snippet b/Packages/Swift/Snippets/struct.sublime-snippet new file mode 100644 index 0000000..137984a --- /dev/null +++ b/Packages/Swift/Snippets/struct.sublime-snippet @@ -0,0 +1,10 @@ + + + struct + source.swift + struct ... + diff --git a/Packages/Swift/Snippets/subscript.sublime-snippet b/Packages/Swift/Snippets/subscript.sublime-snippet new file mode 100644 index 0000000..dfd5399 --- /dev/null +++ b/Packages/Swift/Snippets/subscript.sublime-snippet @@ -0,0 +1,10 @@ + + ${2:ReturnType} { + $3 +} +]]> + subscript + source.swift + subscript ... + diff --git a/Packages/Swift/Snippets/swift.sublime-snippet b/Packages/Swift/Snippets/swift.sublime-snippet new file mode 100644 index 0000000..5aaf407 --- /dev/null +++ b/Packages/Swift/Snippets/swift.sublime-snippet @@ -0,0 +1,9 @@ + + + swift + source.swift + #!/usr/bin/env xcrun swift + diff --git a/Packages/Swift/Snippets/switch.sublime-snippet b/Packages/Swift/Snippets/switch.sublime-snippet new file mode 100644 index 0000000..06327b8 --- /dev/null +++ b/Packages/Swift/Snippets/switch.sublime-snippet @@ -0,0 +1,11 @@ + + + switch + source.swift + switch ... + diff --git a/Packages/Swift/Snippets/typealias.sublime-snippet b/Packages/Swift/Snippets/typealias.sublime-snippet new file mode 100644 index 0000000..fd5c7ba --- /dev/null +++ b/Packages/Swift/Snippets/typealias.sublime-snippet @@ -0,0 +1,8 @@ + + + typealias + source.swift + typealias ... = ... + diff --git a/Packages/Swift/Snippets/willSet.sublime-snippet b/Packages/Swift/Snippets/willSet.sublime-snippet new file mode 100644 index 0000000..ca79a30 --- /dev/null +++ b/Packages/Swift/Snippets/willSet.sublime-snippet @@ -0,0 +1,10 @@ + + + willSet + source.swift + willSet {...} + diff --git a/Packages/Swift/Syntaxes/Swift.JSON-tmLanguage b/Packages/Swift/Syntaxes/Swift.JSON-tmLanguage new file mode 100644 index 0000000..7a83f55 --- /dev/null +++ b/Packages/Swift/Syntaxes/Swift.JSON-tmLanguage @@ -0,0 +1,758 @@ +{ + "name": "Swift", + "scopeName": "source.swift", + "firstLineMatch": "^#!/.*\\bswift", + "uuid": "7efa1168-97c3-4433-8dd7-15b99bf3bb53", + "repository": { + "custom-operator": { + "patterns": [ + { + "name": "keyword.operator.custom.prefix.unary.swift", + "match": "(?<=[\\s(\\[{,;:])([/=\\-+!*%<>&|\\^~.]++)(?![\\s)\\]},;:])" + }, + { + "name": "keyword.operator.custom.postfix.unary.swift", + "match": "(?&|\\^~.]++)(?![\\s)\\]},;:\\.])" + }, + { + "name": "keyword.operator.custom.binary.swift", + "match": "(?<=[\\s(\\[{,;:])([/=\\-+!*%<>&|\\^~.]++)(?=[\\s)\\]},;:])" + } + ] + }, + "operator-declaration-modifier": { + "comment": "operator-declaration", + "name": "keyword.other.operator.swift", + "match": "\\b(operator|prefix|infix|postfix)\\b" + }, + "if-statement-keyword": { + "comment": "if-statement", + "name": "keyword.control.if.swift", + "match": "\\b(if|else)\\b" + }, + "protocol-composition-type": { + "endCaptures": { + "1": { + "name": "punctuation.protocol.end.swift" + } + }, + "match": "\\b(protocol)(<)", + "beginCaptures": { + "1": { + "name": "support.type.protocol.swift" + }, + "2": { + "name": "punctuation.protocol.begin.swift" + } + }, + "patterns": [ + { + "include": "$self" + } + ], + "end": "(>)", + "name": "meta.protocol.swift" + }, + "overflow-operator": { + "name": "keyword.operator.overflow.swift", + "match": "(?&|\\^~.])\\&(\\+|\\-|\\*|\\/|%)(?![/=\\-+!*%<>&|\\^~.])" + }, + "operator": { + "patterns": [ + { + "include": "#comparative-operator" + }, + { + "include": "#assignment-operator" + }, + { + "include": "#logical-operator" + }, + { + "include": "#remainder-operator" + }, + { + "include": "#increment-decrement-operator" + }, + { + "include": "#overflow-operator" + }, + { + "include": "#range-operator" + }, + { + "include": "#bitwise-operator" + }, + { + "include": "#arithmetic-operator" + }, + { + "include": "#ternary-operator" + }, + { + "include": "#type-casting-operator" + }, + { + "include": "#custom-operator" + } + ] + }, + "type-casting-operator": { + "name": "keyword.operator.type-casting.swift", + "match": "\\b(is\\b|as(\\?\\B|\\b))" + }, + "type": { + "comment": "type", + "patterns": [ + { + "include": "#primitive-type" + }, + { + "include": "#integer-type" + }, + { + "include": "#collection-type" + }, + { + "include": "#optional-type" + }, + { + "include": "#protocol-composition-type" + } + ] + }, + "import-declaration": { + "comment": "import-declaration", + "captures": { + "1": { + "name": "keyword.other.import.swift" + }, + "3": { + "name": "support.type.module.import.swift" + }, + "2": { + "name": "storage.modifier.swift" + } + }, + "name": "meta.import.swift", + "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|[/=\\-+!*%<>&|\\^~.]+))*)" + }, + "string-literal": { + "endCaptures": { + "0": { + "name": "string.quoted.double.swift" + } + }, + "beginCaptures": { + "0": { + "name": "string.quoted.double.swift" + } + }, + "patterns": [ + { + "name": "constant.character.escape.swift", + "match": "\\\\([0tnr\\\"\\'\\\\]|x\\h{2}|u\\h{4}|U\\h{8})" + }, + { + "endCaptures": { + "1": { + "name": "support.punctuation.expression.end.swift" + } + }, + "beginCaptures": { + "1": { + "name": "support.punctuation.expression.begin.swift" + } + }, + "contentName": "meta.expression.swift", + "patterns": [ + { + "include": "source.swift" + } + ], + "begin": "(\\\\\\()", + "end": "(\\))" + }, + { + "name": "invalid.illegal.swift", + "match": "(\\\"|\\\\)" + }, + { + "name": "string.quoted.double.swift", + "match": "(.)" + } + ], + "begin": "\\\"", + "end": "\\\"", + "name": "meta.literal.string.swift" + }, + "nil-literal": { + "comment": "nil-literal", + "name": "constant.nil.swift", + "match": "\\bnil\\b" + }, + "bitwise-operator": { + "name": "keyword.operator.bitwise.swift", + "match": "(?&|\\^~.])(&|\\||\\^|<<|>>)(?![/=\\-+!*%<>&|\\^~.])" + }, + "attribute": { + "comment": "attribute", + "patterns": [ + { + "endCaptures": { + "0": { + "name": "punctuation.definition.attribute-arguments.end.swift" + } + }, + "beginCaptures": { + "1": { + "name": "storage.modifier.attribute.swift" + }, + "3": { + "name": "punctuation.definition.attribute-arguments.begin.swift" + }, + "2": { + "name": "punctuation.definition.attribute.swift" + } + }, + "contentName": "meta.attribute.arguments.swift", + "patterns": [ + { + "include": "$self" + } + ], + "begin": "((@)(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B))(\\()", + "end": "\\)" + }, + { + "captures": { + "1": { + "name": "storage.modifier.attribute.swift" + }, + "2": { + "name": "punctuation.definition.attribute.swift" + } + }, + "match": "((@)(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B))" + } + ], + "name": "meta.attribute.swift" + }, + "loop-statement-keyword": { + "comment": "loop-statement", + "name": "keyword.control.loop.swift", + "match": "\\b(while|repeat|for|in)\\b" + }, + "dictionary-type": { + "endCaptures": { + "1": { + "name": "punctuation.dictionary.end.swift" + } + }, + "beginCaptures": { + "1": { + "name": "support.type.dictionary.swift" + }, + "2": { + "name": "punctuation.dictionary.begin.swift" + } + }, + "patterns": [ + { + "include": "$self" + } + ], + "begin": "\\b(Dictionary)(<)", + "end": "(>)", + "name": "meta.dictionary.swift" + }, + "parameter-clause": { + "endCaptures": { + "1": { + "name": "punctuation.definition.function-arguments.end.swift" + } + }, + "beginCaptures": { + "1": { + "name": "punctuation.definition.function-arguments.begin.swift" + } + }, + "comment": "parameter-clause", + "patterns": [ + { + "include": "$self" + } + ], + "begin": "(\\()", + "end": "(\\))", + "name": "meta.parameter-clause.swift" + }, + "comment": { + "comment": "All comment types", + "patterns": [ + { + "include": "#documentation-comment" + }, + { + "include": "#block-comment" + }, + { + "include": "#in-line-comment" + } + ] + }, + "special-literal": { + "name": "keyword.other.literal.swift", + "match": "\\b__(FILE|LINE|COLUMN|FUNCTION)__\\b" + }, + "array-type": { + "endCaptures": { + "1": { + "name": "punctuation.array.end.swift" + } + }, + "beginCaptures": { + "1": { + "name": "support.type.array.swift" + }, + "2": { + "name": "punctuation.array.begin.swift" + } + }, + "patterns": [ + { + "include": "$self" + } + ], + "begin": "\\b(Array)(<)", + "end": "(>)", + "name": "meta.array.swift" + }, + "integer-type": { + "comment": "Int types", + "name": "support.type.swift", + "match": "\\bU?Int(8|16|32|64)?\\b" + }, + "function-declaration": { + "beginCaptures": { + "1": { + "name": "storage.type.function.swift" + }, + "2": { + "name": "entity.type.function.swift" + } + }, + "comment": "function-declaration", + "patterns": [ + { + "include": "#generic-parameter-clause" + }, + { + "include": "#parameter-clause" + }, + { + "include": "#function-result" + }, + { + "include": "#function-body" + } + ], + "begin": "\\b(func)\\s+(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B|[/=\\-+!*%<>&|\\^~.]+)\\s*(?=\\(|<)", + "end": "(?<=\\})", + "name": "meta.function-declaration.swift" + }, + "code-block": { + "endCaptures": { + "1": { + "name": "punctuation.definition.code-block.end.swift" + } + }, + "beginCaptures": { + "1": { + "name": "punctuation.definition.code-block.begin.swift" + } + }, + "comment": "code-block", + "patterns": [ + { + "include": "$self" + } + ], + "begin": "(\\{)", + "end": "(\\})" + }, + "identifier": { + "comment": "identifier", + "name": "meta.identifier.swift", + "match": "(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B)" + }, + "ternary-operator": { + "name": "keyword.operator.ternary.swift", + "match": "(?<=[\\s(\\[{,;:])(\\?|:)(?=[\\s)\\]},;:])" + }, + "function-body": { + "comment": "function-body", + "patterns": [ + { + "include": "#code-block" + } + ], + "name": "meta.function-body.swift" + }, + "control-transfer-statement-keyword": { + "comment": "control-transfer-statement", + "name": "keyword.control.transfer.swift", + "match": "\\b(continue|break|fallthrough|return)\\b" + }, + "boolean": { + "name": "keyword.constant.boolean.swift", + "match": "\\b(true|false)\\b" + }, + "optional-type": { + "endCaptures": { + "1": { + "name": "punctuation.optional.end.swift" + } + }, + "match": "\\b(Optional)(<)", + "beginCaptures": { + "1": { + "name": "support.type.optional.swift" + }, + "2": { + "name": "punctuation.optional.begin.swift" + } + }, + "patterns": [ + { + "include": "$self" + } + ], + "end": "(>)", + "name": "meta.optional.swift" + }, + "arithmetic-operator": { + "name": "keyword.operator.arithmetic.swift", + "match": "(?&|\\^~.])(\\+|\\-|\\*|\\/)(?![/=\\-+!*%<>&|\\^~.])" + }, + "logical-operator": { + "name": "keyword.operator.logical.swift", + "match": "(?&|\\^~.])(!|&&|\\|\\|)(?![/=\\-+!*%<>&|\\^~.])" + }, + "declaration": { + "comment": "declaration", + "patterns": [ + { + "include": "#import-declaration" + }, + { + "include": "#function-declaration" + } + ], + "name": "meta.declaration.swift" + }, + "increment-decrement-operator": { + "name": "keyword.operator.increment-or-decrement.swift", + "match": "(?&|\\^~.])(\\+\\+|\\-\\-)(?![/=\\-+!*%<>&|\\^~.])" + }, + "access-level-modifier": { + "comment": "access-level-modifier", + "name": "keyword.other.access-level-modifier.swift", + "match": "\\b(open|public|internal|fileprivate|private)\\b(?:\\(set\\))?" + }, + "branch-statement-keyword": { + "patterns": [ + { + "include": "#if-statement-keyword" + }, + { + "include": "#switch-statement-keyword" + } + ], + "name": "keyword.control.branch.swift" + }, + "declaration-modifier": { + "comment": "declaration-modifier", + "name": "keyword.other.declaration-modifier.swift", + "match": "\\b(class|convenience|dynamic|final|lazy|(non)?mutating|optional|override|required|static|unowned((un)?safe)?|weak)\\b" + }, + "keyword": { + "patterns": [ + { + "include": "#branch-statement-keyword" + }, + { + "include": "#control-transfer-statement-keyword" + }, + { + "include": "#loop-statement-keyword" + }, + { + "include": "#catch-statement-keyword" + }, + { + "include": "#operator-declaration-modifier" + }, + { + "include": "#declaration-modifier" + }, + { + "include": "#access-level-modifier" + }, + { + "comment": "declaration keyword", + "name": "keyword.declaration.swift", + "match": "\\b(class|deinit|enum|extension|func|import|init|let|protocol|static|struct|subscript|typealias|var|throws|rethrows)\\b" + }, + { + "comment": "statement keyword", + "name": "keyword.statement.swift", + "match": "\\b(break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|repeat|catch|guard|defer|try|throw)\\b" + }, + { + "comment": "expression and type keyword", + "name": "keyword.other.statement.swift", + "match": "\\b(as|dynamicType|is|new|super|self|Self|Type)\\b" + }, + { + "comment": "other keyword", + "name": "keyword.other.swift", + "match": "\\b(associativity|didSet|get|infix|inout|left|mutating|none|nonmutating|operator|override|postfix|precedence|prefix|right|set|unowned((un)?safe)?|weak|willSet)\\b" + } + ] + }, + "catch-statement-keyword": { + "comment": "catch-statement", + "name": "kewyord.control.catch.swift", + "match": "\\b(catch|do)\\b" + }, + "generic-parameter-clause": { + "endCaptures": { + "1": { + "name": "punctuation.definition.generic-parameter-clause.end.swift" + } + }, + "beginCaptures": { + "1": { + "name": "punctuation.definition.generic-parameter-clause.begin.swift" + } + }, + "comment": "generic-parameter-clause", + "patterns": [ + { + "include": "$self" + } + ], + "begin": "(<)", + "end": "(>)", + "name": "meta.generic-parameter-clause.swift" + }, + "comparative-operator": { + "name": "keyword.operator.comparative.swift", + "match": "(?&|\\^~.])((=|!)==?|(<|>)=?|~=)(?![/=\\-+!*%<>&|\\^~.])" + }, + "literal": { + "patterns": [ + { + "include": "#integer-literal" + }, + { + "include": "#floating-point-literal" + }, + { + "include": "#nil-literal" + }, + { + "include": "#string-literal" + }, + { + "include": "#special-literal" + } + ] + }, + "in-line-comment": { + "comment": "In-line comment", + "captures": { + "1": { + "name": "punctuation.definition.comment.line.double-slash.swift" + } + }, + "name": "comment.line.double-slash.swift", + "match": "(//).*" + }, + "storage-type": { + "name": "storage.type.swift", + "match": "\\b(var|func|let|class|enum|struct|protocol|extension|typealias)\\b" + }, + "primitive-type": { + "comment": "Primitive types", + "name": "support.type.swift", + "match": "\\b(Int|Float|Double|String|Bool|Character|Void)\\b" + }, + "shebang-line": { + "comment": "Shebang line", + "captures": { + "1": { + "name": "punctuation.definition.comment.line.shebang.swift" + } + }, + "name": "comment.line.shebang.swift", + "match": "^(#!).*$" + }, + "function-result": { + "beginCaptures": { + "1": { + "name": "keyword.operator.function-result.swift" + } + }, + "comment": "function-result", + "patterns": [ + { + "include": "#type" + } + ], + "begin": "(?&|\\^~.])(\\->)(?![/=\\-+!*%<>&|\\^~.])\\s*", + "end": "\\s*(?=\\{)", + "name": "meta.function-result.swift" + }, + "floating-point-literal": { + "patterns": [ + { + "comment": "floating-point-literal -> (decimal-literal)(decimal-fraction)?(decimal-exponent)?", + "match": "\\b([0-9][0-9_]*)(\\.([0-9][0-9_]*))?([eE][+\\-]?([0-9][0-9_]*))?\\b" + }, + { + "comment": "floating-point-literal -> (hexadecimal-literal)(hexadecimal-fraction)?(hexadecimal-exponent)", + "match": "\\b(0x\\h[\\h_]*)(\\.(0x\\h[\\h_]*))?([pP][+\\-]?(0x\\h[\\h_]*))\\b" + } + ], + "name": "constant.numeric.floating-point.swift" + }, + "collection-type": { + "comment": "Collection types", + "patterns": [ + { + "include": "#array-type" + }, + { + "include": "#dictionary-type" + }, + { + "name": "support.type.swift", + "match": "\\b(Array|Dictionary)\\b" + } + ] + }, + "assignment-operator": { + "name": "keyword.operator.assignment.swift", + "match": "(?&|\\^~.])(\\+|\\-|\\*|\\/|%|<<|>>|&|\\^|\\||&&|\\|\\|)?=(?![/=\\-+!*%<>&|\\^~.])" + }, + "block-comment": { + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.block.end.swift" + } + }, + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.block.begin.swift" + } + }, + "comment": "Block comment", + "begin": "/\\*", + "end": "\\*/", + "name": "comment.block.swift" + }, + "switch-statement-keyword": { + "comment": "switch-statement", + "name": "keyword.control.switch.swift", + "match": "\\b(switch|case|default|where)\\b" + }, + "remainder-operator": { + "name": "keyword.operator.remainder.swift", + "match": "(?&|\\^~.])\\%(?![/=\\-+!*%<>&|\\^~.])" + }, + "documentation-comment": { + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.block.documentation.end.swift" + } + }, + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.block.documentation.begin.swift" + } + }, + "comment": "Documentation comment", + "begin": "/\\*\\*", + "end": "\\*/", + "name": "comment.block.documentation.swift" + }, + "integer-literal": { + "patterns": [ + { + "comment": "binary-literal", + "name": "constant.numeric.integer.binary.swift", + "match": "(\\B\\-|\\b)(0b[01][01_]*)\\b" + }, + { + "comment": "octal-literal", + "name": "constant.numeric.integer.octal.swift", + "match": "(\\B\\-|\\b)(0o[0-7][0-7_]*)\\b" + }, + { + "comment": "decimal-literal", + "name": "constant.numeric.integer.decimal.swift", + "match": "(\\B\\-|\\b)([0-9][0-9_]*)\\b" + }, + { + "comment": "hexadecimal-literal", + "name": "constant.numeric.integer.hexadecimal.swift", + "match": "(\\B\\-|\\b)(0x\\h[\\h_]*)\\b" + } + ], + "name": "constant.numeric.integer.swift" + }, + "range-operator": { + "name": "keyword.operator.range.swift", + "match": "(?&|\\^~.])\\.\\.(?:\\.)?(?![/=\\-+!*%<>&|\\^~.])" + } + }, + "author": "Matt Alexander - matt@queg.net", + "keyEquivalent": "^~S", + "fileTypes": [ + "swift" + ], + "patterns": [ + { + "include": "#shebang-line" + }, + { + "include": "#comment" + }, + { + "include": "#attribute" + }, + { + "include": "#literal" + }, + { + "include": "#operator" + }, + { + "include": "#declaration" + }, + { + "include": "#storage-type" + }, + { + "include": "#keyword" + }, + { + "include": "#type" + }, + { + "include": "#boolean" + } + ] +} diff --git a/Packages/Swift/Syntaxes/Swift.YAML-tmLanguage b/Packages/Swift/Syntaxes/Swift.YAML-tmLanguage new file mode 100644 index 0000000..e3003b0 --- /dev/null +++ b/Packages/Swift/Syntaxes/Swift.YAML-tmLanguage @@ -0,0 +1,441 @@ +# author: Matt Alexander - matt@queg.net +# [PackageDev] target_format: plist, source_format: yaml, ext: tmLanguage +# [PackageDev] target_format: json, source_format: yaml, ext: JSON-tmLanguage +--- +name: Swift +scopeName: source.swift +author: Matt Alexander - matt@queg.net +fileTypes: [swift] +uuid: 7efa1168-97c3-4433-8dd7-15b99bf3bb53 +keyEquivalent: ^~S +firstLineMatch: ^#!/.*\bswift + +patterns: +- include: '#shebang-line' +- include: '#comment' +- include: '#attribute' +- include: '#literal' +- include: '#operator' +- include: '#declaration' +- include: '#storage-type' +- include: '#keyword' +- include: '#type' +- include: '#boolean' + +repository: + +# Identifier + identifier: + comment: identifier + name: meta.identifier.swift + match: (\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B) + + +# Keywords + keyword: + patterns: + - include: '#branch-statement-keyword' + - include: '#control-transfer-statement-keyword' + - include: '#loop-statement-keyword' + - include: '#catch-statement-keyword' + - include: '#operator-declaration-modifier' + - include: '#declaration-modifier' + - include: '#access-level-modifier' + - comment: declaration keyword + name: keyword.declaration.swift + match: \b(class|deinit|enum|extension|func|import|init|let|protocol|static|struct|subscript|typealias|var|throws|rethrows)\b + - comment: statement keyword + name: keyword.statement.swift + match: \b(break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|repeat|catch|guard|defer|try|throw)\b + - comment: expression and type keyword + name: keyword.other.statement.swift + match: \b(as|dynamicType|is|new|super|self|Self|Type)\b + - comment: other keyword + name: keyword.other.swift + match: \b(associativity|didSet|get|infix|inout|left|mutating|none|nonmutating|operator|override|postfix|precedence|prefix|right|set|unowned((un)?safe)?|weak|willSet)\b + branch-statement-keyword: + name: keyword.control.branch.swift + patterns: + - include: '#if-statement-keyword' + - include: '#switch-statement-keyword' + switch-statement-keyword: + comment: switch-statement + name: keyword.control.switch.swift + match: \b(switch|case|default|where)\b + if-statement-keyword: + comment: if-statement + name: keyword.control.if.swift + match: \b(if|else)\b + control-transfer-statement-keyword: + comment: control-transfer-statement + name: keyword.control.transfer.swift + match: \b(continue|break|fallthrough|return)\b + loop-statement-keyword: + comment: loop-statement + name: keyword.control.loop.swift + match: \b(while|repeat|for|in)\b + catch-statement-keyword: + comment: catch-statement + name: kewyord.control.catch.swift + match: \b(catch|do)\b + operator-declaration-modifier: + comment: operator-declaration + name: keyword.other.operator.swift + match: \b(operator|prefix|infix|postfix)\b + access-level-modifier: + comment: access-level-modifier + name: keyword.other.access-level-modifier.swift + match: \b(open|public|internal|fileprivate|private)\b(?:\(set\))? + declaration-modifier: + comment: declaration-modifier + name: keyword.other.declaration-modifier.swift + match: \b(class|convenience|dynamic|final|lazy|(non)?mutating|optional|override|required|static|unowned((un)?safe)?|weak)\b + + +# Storage types + storage-type: + name: storage.type.swift + match: \b(var|func|let|class|enum|struct|protocol|extension|typealias)\b + + +# Operators + operator: + patterns: + - include: '#comparative-operator' + - include: '#assignment-operator' + - include: '#logical-operator' + - include: '#remainder-operator' + - include: '#increment-decrement-operator' + - include: '#overflow-operator' + - include: '#range-operator' + - include: '#bitwise-operator' + - include: '#arithmetic-operator' + - include: '#ternary-operator' + - include: '#type-casting-operator' + - include: '#custom-operator' + comparative-operator: + name: keyword.operator.comparative.swift + match: (?&|\^~.])((=|!)==?|(<|>)=?|~=)(?![/=\-+!*%<>&|\^~.]) + assignment-operator: + name: keyword.operator.assignment.swift + match: (?&|\^~.])(\+|\-|\*|\/|%|<<|>>|&|\^|\||&&|\|\|)?=(?![/=\-+!*%<>&|\^~.]) + logical-operator: + name: keyword.operator.logical.swift + match: (?&|\^~.])(!|&&|\|\|)(?![/=\-+!*%<>&|\^~.]) + remainder-operator: + name: keyword.operator.remainder.swift + match: (?&|\^~.])\%(?![/=\-+!*%<>&|\^~.]) + increment-decrement-operator: + name: keyword.operator.increment-or-decrement.swift + match: (?&|\^~.])(\+\+|\-\-)(?![/=\-+!*%<>&|\^~.]) + overflow-operator: + name: keyword.operator.overflow.swift + match: (?&|\^~.])\&(\+|\-|\*|\/|%)(?![/=\-+!*%<>&|\^~.]) + range-operator: + name: keyword.operator.range.swift + match: (?&|\^~.])\.\.(?:\.)?(?![/=\-+!*%<>&|\^~.]) + arithmetic-operator: + name: keyword.operator.arithmetic.swift + match: (?&|\^~.])(\+|\-|\*|\/)(?![/=\-+!*%<>&|\^~.]) + bitwise-operator: + name: keyword.operator.bitwise.swift + match: (?&|\^~.])(&|\||\^|<<|>>)(?![/=\-+!*%<>&|\^~.]) + ternary-operator: + name: keyword.operator.ternary.swift + match: (?<=[\s(\[{,;:])(\?|:)(?=[\s)\]},;:]) + type-casting-operator: + name: keyword.operator.type-casting.swift + match: \b(is\b|as(\?\B|\b)) + custom-operator: + patterns: + - name: keyword.operator.custom.prefix.unary.swift + match: (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:]) + - name: keyword.operator.custom.postfix.unary.swift + match: (?&|\^~.]++)(?![\s)\]},;:\.]) + - name: keyword.operator.custom.binary.swift + match: (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?=[\s)\]},;:]) + + +# Literal Expressions + literal: + patterns: + - include: '#integer-literal' + - include: '#floating-point-literal' + - include: '#nil-literal' + - include: '#string-literal' + - include: '#special-literal' + integer-literal: + name: constant.numeric.integer.swift + patterns: + - comment: binary-literal + name: constant.numeric.integer.binary.swift + match: (\B\-|\b)(0b[01][01_]*)\b + - comment: octal-literal + name: constant.numeric.integer.octal.swift + match: (\B\-|\b)(0o[0-7][0-7_]*)\b + - comment: decimal-literal + name: constant.numeric.integer.decimal.swift + match: (\B\-|\b)([0-9][0-9_]*)\b + - comment: hexadecimal-literal + name: constant.numeric.integer.hexadecimal.swift + match: (\B\-|\b)(0x\h[\h_]*)\b + floating-point-literal: + name: constant.numeric.floating-point.swift + patterns: + - comment: floating-point-literal -> (decimal-literal)(decimal-fraction)?(decimal-exponent)? + match: \b([0-9][0-9_]*)(\.([0-9][0-9_]*))?([eE][+\-]?([0-9][0-9_]*))?\b + - comment: floating-point-literal -> (hexadecimal-literal)(hexadecimal-fraction)?(hexadecimal-exponent) + match: \b(0x\h[\h_]*)(\.(0x\h[\h_]*))?([pP][+\-]?(0x\h[\h_]*))\b + nil-literal: + comment: nil-literal + name: constant.nil.swift + match: \bnil\b + string-literal: + name: meta.literal.string.swift + begin: \" + end: \" + beginCaptures: + '0': { name: string.quoted.double.swift } + endCaptures: + '0': { name: string.quoted.double.swift } + patterns: + - name: constant.character.escape.swift + match: \\([0tnr\"\'\\]|x\h{2}|u\h{4}|U\h{8}) + - contentName: meta.expression.swift + begin: (\\\() + end: (\)) + beginCaptures: + '1': { name: support.punctuation.expression.begin.swift } + endCaptures: + '1': { name: support.punctuation.expression.end.swift } + patterns: + - include: source.swift + - name: invalid.illegal.swift + match: (\"|\\) + - name: string.quoted.double.swift + match: (.) + special-literal: + name: keyword.other.literal.swift + match: \b__(FILE|LINE|COLUMN|FUNCTION)__\b + + +# Primitive values + boolean: + name: keyword.constant.boolean.swift + match: \b(true|false)\b + + +# Type names + type: + comment: type + patterns: + - include: '#primitive-type' + - include: '#integer-type' + - include: '#collection-type' + - include: '#optional-type' + - include: '#protocol-composition-type' + primitive-type: + comment: Primitive types + name: support.type.swift + match: \b(Int|Float|Double|String|Bool|Character|Void)\b + integer-type: + comment: Int types + name: support.type.swift + match: \bU?Int(8|16|32|64)?\b + collection-type: + comment: Collection types + patterns: + - include: '#array-type' + - include: '#dictionary-type' + - name: support.type.swift + match: \b(Array|Dictionary)\b + array-type: + name: meta.array.swift + begin: \b(Array)(<) + end: (>) + beginCaptures: + '1': { name: support.type.array.swift } + '2': { name: punctuation.array.begin.swift } + endCaptures: + '1': {name: punctuation.array.end.swift} + patterns: + - include: $self + dictionary-type: + name: meta.dictionary.swift + begin: \b(Dictionary)(<) + end: (>) + beginCaptures: + '1': { name: support.type.dictionary.swift } + '2': { name: punctuation.dictionary.begin.swift } + endCaptures: + '1': {name: punctuation.dictionary.end.swift} + patterns: + - include: $self + optional-type: + name: meta.optional.swift + match: \b(Optional)(<) + end: (>) + beginCaptures: + '1': { name: support.type.optional.swift } + '2': { name: punctuation.optional.begin.swift } + endCaptures: + '1': { name: punctuation.optional.end.swift } + patterns: + - include: $self + protocol-composition-type: + name: meta.protocol.swift + match: \b(protocol)(<) + end: (>) + beginCaptures: + '1': { name: support.type.protocol.swift } + '2': { name: punctuation.protocol.begin.swift } + endCaptures: + '1': { name: punctuation.protocol.end.swift } + patterns: + - include: $self + +# Attributes + attribute: + comment: attribute + name: meta.attribute.swift + patterns: + - begin: ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B))(\() + end: \) + contentName: meta.attribute.arguments.swift + beginCaptures: + '1': { name: storage.modifier.attribute.swift } + '2': { name: punctuation.definition.attribute.swift } + '3': { name: punctuation.definition.attribute-arguments.begin.swift } + endCaptures: + '0': { name: punctuation.definition.attribute-arguments.end.swift } + patterns: + - include: $self + - match: ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B)) + captures: + '1': { name: storage.modifier.attribute.swift } + '2': { name: punctuation.definition.attribute.swift } + + +# Declarations + declaration: + comment: declaration + name: meta.declaration.swift + patterns: + - include: '#import-declaration' + - include: '#function-declaration' + +# Import Declaration + import-declaration: + comment: import-declaration + name: meta.import.swift + 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|[/=\-+!*%<>&|\^~.]+))*) + captures: + '1': { name: keyword.other.import.swift } + '2': { name: storage.modifier.swift } + '3': { name: support.type.module.import.swift } + +# Function Declaration + function-declaration: + comment: function-declaration + name: meta.function-declaration.swift + begin: \b(func)\s+(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B|[/=\-+!*%<>&|\^~.]+)\s*(?=\(|<) + end: (?<=\}) + beginCaptures: + '1': { name: storage.type.function.swift } + '2': { name: entity.type.function.swift } + patterns: + - include: '#generic-parameter-clause' + - include: '#parameter-clause' + - include: '#function-result' + - include: '#function-body' + parameter-clause: + comment: parameter-clause + name: meta.parameter-clause.swift + begin: (\() + end: (\)) + beginCaptures: + '1': { name: punctuation.definition.function-arguments.begin.swift } + endCaptures: + '1': { name: punctuation.definition.function-arguments.end.swift } + patterns: + - include: $self + function-result: + comment: function-result + name: meta.function-result.swift + begin: (?&|\^~.])(\->)(?![/=\-+!*%<>&|\^~.])\s* + end: \s*(?=\{) + beginCaptures: + '1': { name: keyword.operator.function-result.swift } + patterns: + - include: '#type' + function-body: + comment: function-body + name: meta.function-body.swift + patterns: + - include: '#code-block' + + + generic-parameter-clause: + comment: generic-parameter-clause + name: meta.generic-parameter-clause.swift + begin: (<) + end: (>) + beginCaptures: + '1': { name: punctuation.definition.generic-parameter-clause.begin.swift } + endCaptures: + '1': { name: punctuation.definition.generic-parameter-clause.end.swift } + patterns: + - include: $self + + code-block: + comment: code-block + begin: (\{) + end: (\}) + beginCaptures: + '1': { name: punctuation.definition.code-block.begin.swift } + endCaptures: + '1': { name: punctuation.definition.code-block.end.swift } + patterns: + - include: $self + + +# Comments + comment: + comment: All comment types + patterns: + - include: '#documentation-comment' + - include: '#block-comment' + - include: '#in-line-comment' + documentation-comment: + comment: Documentation comment + name: comment.block.documentation.swift + begin: /\*\* + end: \*/ + beginCaptures: + '0': { name: punctuation.definition.comment.block.documentation.begin.swift } + endCaptures: + '0': { name: punctuation.definition.comment.block.documentation.end.swift } + block-comment: + comment: Block comment + name: comment.block.swift + begin: /\* + end: \*/ + beginCaptures: + '0': { name: punctuation.definition.comment.block.begin.swift } + endCaptures: + '0': { name: punctuation.definition.comment.block.end.swift } + in-line-comment: + comment: In-line comment + name: comment.line.double-slash.swift + match: (//).* + captures: + '1': { name: punctuation.definition.comment.line.double-slash.swift } + + shebang-line: + comment: Shebang line + name: comment.line.shebang.swift + match: ^(#!).*$ + captures: + '1': { name: punctuation.definition.comment.line.shebang.swift } + +... diff --git a/Packages/Swift/Syntaxes/Swift.sublime-syntax b/Packages/Swift/Syntaxes/Swift.sublime-syntax new file mode 100644 index 0000000..9194cc3 --- /dev/null +++ b/Packages/Swift/Syntaxes/Swift.sublime-syntax @@ -0,0 +1,371 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Swift +file_extensions: + - swift +first_line_match: ^#!/.*\bswift +scope: source.swift +contexts: + main: + - include: shebang-line + - include: comment + - include: attribute + - include: literal + - include: operator + - include: declaration + - include: storage-type + - include: keyword + - include: type + - include: boolean + comment: + - include: documentation-comment + - include: block-comment + - include: in-line-comment + access-level-modifier: + - match: \b(open|public|internal|fileprivate|private)\b(?:\(set\))? + comment: access-level-modifier + scope: keyword.other.access-level-modifier.swift + arithmetic-operator: + - match: '(?&|\^~.])(\+|\-|\*|\/)(?![/=\-+!*%<>&|\^~.])' + scope: keyword.operator.arithmetic.swift + array-type: + - match: \b(Array)(<) + captures: + 1: support.type.array.swift + 2: punctuation.array.begin.swift + push: + - meta_scope: meta.array.swift + - match: (>) + captures: + 1: punctuation.array.end.swift + pop: true + - include: main + assignment-operator: + - match: '(?&|\^~.])(\+|\-|\*|\/|%|<<|>>|&|\^|\||&&|\|\|)?=(?![/=\-+!*%<>&|\^~.])' + scope: keyword.operator.assignment.swift + attribute: + - match: '((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B))(\()' + captures: + 1: storage.modifier.attribute.swift + 2: punctuation.definition.attribute.swift + 3: punctuation.definition.attribute-arguments.begin.swift + push: + - meta_content_scope: meta.attribute.arguments.swift + - match: \) + captures: + 0: punctuation.definition.attribute-arguments.end.swift + pop: true + - include: main + - match: '((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B))' + captures: + 1: storage.modifier.attribute.swift + 2: punctuation.definition.attribute.swift + bitwise-operator: + - match: '(?&|\^~.])(&|\||\^|<<|>>)(?![/=\-+!*%<>&|\^~.])' + scope: keyword.operator.bitwise.swift + block-comment: + - match: /\* + comment: Block comment + captures: + 0: punctuation.definition.comment.block.begin.swift + push: + - meta_scope: comment.block.swift + - match: \*/ + captures: + 0: punctuation.definition.comment.block.end.swift + pop: true + boolean: + - match: \b(true|false)\b + scope: keyword.constant.boolean.swift + branch-statement-keyword: + - include: if-statement-keyword + - include: switch-statement-keyword + catch-statement-keyword: + - match: \b(catch|do)\b + comment: catch-statement + scope: kewyord.control.catch.swift + code-block: + - match: '(\{)' + comment: code-block + captures: + 1: punctuation.definition.code-block.begin.swift + push: + - match: '(\})' + captures: + 1: punctuation.definition.code-block.end.swift + pop: true + - include: main + collection-type: + - include: array-type + - include: dictionary-type + - match: \b(Array|Dictionary)\b + scope: support.type.swift + comparative-operator: + - match: '(?&|\^~.])((=|!)==?|(<|>)=?|~=)(?![/=\-+!*%<>&|\^~.])' + scope: keyword.operator.comparative.swift + control-transfer-statement-keyword: + - match: \b(continue|break|fallthrough|return)\b + comment: control-transfer-statement + scope: keyword.control.transfer.swift + custom-operator: + - match: '(?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:])' + scope: keyword.operator.custom.prefix.unary.swift + - match: '(?&|\^~.]++)(?![\s)\]},;:\.])' + scope: keyword.operator.custom.postfix.unary.swift + - match: '(?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?=[\s)\]},;:])' + scope: keyword.operator.custom.binary.swift + declaration: + - include: import-declaration + - include: function-declaration + declaration-modifier: + - match: \b(class|convenience|dynamic|final|lazy|(non)?mutating|optional|override|required|static|unowned((un)?safe)?|weak)\b + comment: declaration-modifier + scope: keyword.other.declaration-modifier.swift + dictionary-type: + - match: \b(Dictionary)(<) + captures: + 1: support.type.dictionary.swift + 2: punctuation.dictionary.begin.swift + push: + - meta_scope: meta.dictionary.swift + - match: (>) + captures: + 1: punctuation.dictionary.end.swift + pop: true + - include: main + documentation-comment: + - match: /\*\* + comment: Documentation comment + captures: + 0: punctuation.definition.comment.block.documentation.begin.swift + push: + - meta_scope: comment.block.documentation.swift + - match: \*/ + captures: + 0: punctuation.definition.comment.block.documentation.end.swift + pop: true + floating-point-literal: + - match: '\b([0-9][0-9_]*)(\.([0-9][0-9_]*))?([eE][+\-]?([0-9][0-9_]*))?\b' + comment: floating-point-literal -> (decimal-literal)(decimal-fraction)?(decimal-exponent)? + - match: '\b(0x\h[\h_]*)(\.(0x\h[\h_]*))?([pP][+\-]?(0x\h[\h_]*))\b' + comment: floating-point-literal -> (hexadecimal-literal)(hexadecimal-fraction)?(hexadecimal-exponent) + function-body: + - include: code-block + function-declaration: + - match: '\b(func)\s+(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B|[/=\-+!*%<>&|\^~.]+)\s*(?=\(|<)' + comment: function-declaration + captures: + 1: storage.type.function.swift + 2: entity.type.function.swift + push: + - meta_scope: meta.function-declaration.swift + - match: '(?<=\})' + pop: true + - include: generic-parameter-clause + - include: parameter-clause + - include: function-result + - include: function-body + function-result: + - match: '(?&|\^~.])(\->)(?![/=\-+!*%<>&|\^~.])\s*' + comment: function-result + captures: + 1: keyword.operator.function-result.swift + push: + - meta_scope: meta.function-result.swift + - match: '\s*(?=\{)' + pop: true + - include: type + generic-parameter-clause: + - match: (<) + comment: generic-parameter-clause + captures: + 1: punctuation.definition.generic-parameter-clause.begin.swift + push: + - meta_scope: meta.generic-parameter-clause.swift + - match: (>) + captures: + 1: punctuation.definition.generic-parameter-clause.end.swift + pop: true + - include: main + identifier: + - match: '(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B)' + comment: identifier + scope: meta.identifier.swift + if-statement-keyword: + - match: \b(if|else)\b + comment: if-statement + scope: keyword.control.if.swift + import-declaration: + - 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|[/=\-+!*%<>&|\^~.]+))*)' + comment: import-declaration + scope: meta.import.swift + captures: + 1: keyword.other.import.swift + 2: storage.modifier.swift + 3: support.type.module.import.swift + in-line-comment: + - match: (//).* + comment: In-line comment + scope: comment.line.double-slash.swift + captures: + 1: punctuation.definition.comment.line.double-slash.swift + increment-decrement-operator: + - match: '(?&|\^~.])(\+\+|\-\-)(?![/=\-+!*%<>&|\^~.])' + scope: keyword.operator.increment-or-decrement.swift + integer-literal: + - match: '(\B\-|\b)(0b[01][01_]*)\b' + comment: binary-literal + scope: constant.numeric.integer.binary.swift + - match: '(\B\-|\b)(0o[0-7][0-7_]*)\b' + comment: octal-literal + scope: constant.numeric.integer.octal.swift + - match: '(\B\-|\b)([0-9][0-9_]*)\b' + comment: decimal-literal + scope: constant.numeric.integer.decimal.swift + - match: '(\B\-|\b)(0x\h[\h_]*)\b' + comment: hexadecimal-literal + scope: constant.numeric.integer.hexadecimal.swift + integer-type: + - match: \bU?Int(8|16|32|64)?\b + comment: Int types + scope: support.type.swift + keyword: + - include: branch-statement-keyword + - include: control-transfer-statement-keyword + - include: loop-statement-keyword + - include: catch-statement-keyword + - include: operator-declaration-modifier + - include: declaration-modifier + - include: access-level-modifier + - match: \b(class|deinit|enum|extension|func|import|init|let|protocol|static|struct|subscript|typealias|var|throws|rethrows)\b + comment: declaration keyword + scope: keyword.declaration.swift + - match: \b(break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|repeat|catch|guard|defer|try|throw)\b + comment: statement keyword + scope: keyword.statement.swift + - match: \b(as|dynamicType|is|new|super|self|Self|Type)\b + comment: expression and type keyword + scope: keyword.other.statement.swift + - match: \b(associativity|didSet|get|infix|inout|left|mutating|none|nonmutating|operator|override|postfix|precedence|prefix|right|set|unowned((un)?safe)?|weak|willSet)\b + comment: other keyword + scope: keyword.other.swift + literal: + - include: integer-literal + - include: floating-point-literal + - include: nil-literal + - include: string-literal + - include: special-literal + logical-operator: + - match: '(?&|\^~.])(!|&&|\|\|)(?![/=\-+!*%<>&|\^~.])' + scope: keyword.operator.logical.swift + loop-statement-keyword: + - match: \b(while|repeat|for|in)\b + comment: loop-statement + scope: keyword.control.loop.swift + nil-literal: + - match: \bnil\b + comment: nil-literal + scope: constant.nil.swift + operator: + - include: comparative-operator + - include: assignment-operator + - include: logical-operator + - include: remainder-operator + - include: increment-decrement-operator + - include: overflow-operator + - include: range-operator + - include: bitwise-operator + - include: arithmetic-operator + - include: ternary-operator + - include: type-casting-operator + - include: custom-operator + operator-declaration-modifier: + - match: \b(operator|prefix|infix|postfix)\b + comment: operator-declaration + scope: keyword.other.operator.swift + optional-type: + - match: \b(Optional)(<) + scope: meta.optional.swift + overflow-operator: + - match: '(?&|\^~.])\&(\+|\-|\*|\/|%)(?![/=\-+!*%<>&|\^~.])' + scope: keyword.operator.overflow.swift + parameter-clause: + - match: (\() + comment: parameter-clause + captures: + 1: punctuation.definition.function-arguments.begin.swift + push: + - meta_scope: meta.parameter-clause.swift + - match: (\)) + captures: + 1: punctuation.definition.function-arguments.end.swift + pop: true + - include: main + primitive-type: + - match: \b(Int|Float|Double|String|Bool|Character|Void)\b + comment: Primitive types + scope: support.type.swift + protocol-composition-type: + - match: \b(protocol)(<) + scope: meta.protocol.swift + range-operator: + - match: '(?&|\^~.])\.\.(?:\.)?(?![/=\-+!*%<>&|\^~.])' + scope: keyword.operator.range.swift + remainder-operator: + - match: '(?&|\^~.])\%(?![/=\-+!*%<>&|\^~.])' + scope: keyword.operator.remainder.swift + shebang-line: + - match: ^(#!).*$ + comment: Shebang line + scope: comment.line.shebang.swift + captures: + 1: punctuation.definition.comment.line.shebang.swift + special-literal: + - match: \b__(FILE|LINE|COLUMN|FUNCTION)__\b + scope: keyword.other.literal.swift + storage-type: + - match: \b(var|func|let|class|enum|struct|protocol|extension|typealias)\b + scope: storage.type.swift + string-literal: + - match: \" + captures: + 0: string.quoted.double.swift + push: + - meta_scope: meta.literal.string.swift + - match: \" + captures: + 0: string.quoted.double.swift + pop: true + - match: '\\([0tnr\"\''\\]|x\h{2}|u\h{4}|U\h{8})' + scope: constant.character.escape.swift + - match: (\\\() + captures: + 1: support.punctuation.expression.begin.swift + push: + - meta_content_scope: meta.expression.swift + - match: (\)) + captures: + 1: support.punctuation.expression.end.swift + pop: true + - include: scope:source.swift + - match: (\"|\\) + scope: invalid.illegal.swift + - match: (.) + scope: string.quoted.double.swift + switch-statement-keyword: + - match: \b(switch|case|default|where)\b + comment: switch-statement + scope: keyword.control.switch.swift + ternary-operator: + - match: '(?<=[\s(\[{,;:])(\?|:)(?=[\s)\]},;:])' + scope: keyword.operator.ternary.swift + type: + - include: primitive-type + - include: integer-type + - include: collection-type + - include: optional-type + - include: protocol-composition-type + type-casting-operator: + - match: \b(is\b|as(\?\B|\b)) + scope: keyword.operator.type-casting.swift diff --git a/Packages/Swift/Syntaxes/Swift.tmLanguage b/Packages/Swift/Syntaxes/Swift.tmLanguage new file mode 100644 index 0000000..9993e0e --- /dev/null +++ b/Packages/Swift/Syntaxes/Swift.tmLanguage @@ -0,0 +1,1199 @@ + + + + + author + Matt Alexander - matt@queg.net + fileTypes + + swift + + firstLineMatch + ^#!/.*\bswift + keyEquivalent + ^~S + name + Swift + patterns + + + include + #shebang-line + + + include + #comment + + + include + #attribute + + + include + #literal + + + include + #operator + + + include + #declaration + + + include + #storage-type + + + include + #keyword + + + include + #type + + + include + #boolean + + + repository + + access-level-modifier + + comment + access-level-modifier + match + \b(open|public|internal|fileprivate|private)\b(?:\(set\))? + name + keyword.other.access-level-modifier.swift + + arithmetic-operator + + match + (?<![/=\-+!*%<>&|\^~.])(\+|\-|\*|\/)(?![/=\-+!*%<>&|\^~.]) + name + keyword.operator.arithmetic.swift + + array-type + + begin + \b(Array)(<) + beginCaptures + + 1 + + name + support.type.array.swift + + 2 + + name + punctuation.array.begin.swift + + + end + (>) + endCaptures + + 1 + + name + punctuation.array.end.swift + + + name + meta.array.swift + patterns + + + include + $self + + + + assignment-operator + + match + (?<![/=\-+!*%<>&|\^~.])(\+|\-|\*|\/|%|<<|>>|&|\^|\||&&|\|\|)?=(?![/=\-+!*%<>&|\^~.]) + name + keyword.operator.assignment.swift + + attribute + + comment + attribute + name + meta.attribute.swift + patterns + + + begin + ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B))(\() + beginCaptures + + 1 + + name + storage.modifier.attribute.swift + + 2 + + name + punctuation.definition.attribute.swift + + 3 + + name + punctuation.definition.attribute-arguments.begin.swift + + + contentName + meta.attribute.arguments.swift + end + \) + endCaptures + + 0 + + name + punctuation.definition.attribute-arguments.end.swift + + + patterns + + + include + $self + + + + + captures + + 1 + + name + storage.modifier.attribute.swift + + 2 + + name + punctuation.definition.attribute.swift + + + match + ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B)) + + + + bitwise-operator + + match + (?<![/=\-+!*%<>&|\^~.])(&|\||\^|<<|>>)(?![/=\-+!*%<>&|\^~.]) + name + keyword.operator.bitwise.swift + + block-comment + + begin + /\* + beginCaptures + + 0 + + name + punctuation.definition.comment.block.begin.swift + + + comment + Block comment + end + \*/ + endCaptures + + 0 + + name + punctuation.definition.comment.block.end.swift + + + name + comment.block.swift + + boolean + + match + \b(true|false)\b + name + keyword.constant.boolean.swift + + branch-statement-keyword + + name + keyword.control.branch.swift + patterns + + + include + #if-statement-keyword + + + include + #switch-statement-keyword + + + + catch-statement-keyword + + comment + catch-statement + match + \b(catch|do)\b + name + kewyord.control.catch.swift + + code-block + + begin + (\{) + beginCaptures + + 1 + + name + punctuation.definition.code-block.begin.swift + + + comment + code-block + end + (\}) + endCaptures + + 1 + + name + punctuation.definition.code-block.end.swift + + + patterns + + + include + $self + + + + collection-type + + comment + Collection types + patterns + + + include + #array-type + + + include + #dictionary-type + + + match + \b(Array|Dictionary)\b + name + support.type.swift + + + + comment + + comment + All comment types + patterns + + + include + #documentation-comment + + + include + #block-comment + + + include + #in-line-comment + + + + comparative-operator + + match + (?<![/=\-+!*%<>&|\^~.])((=|!)==?|(<|>)=?|~=)(?![/=\-+!*%<>&|\^~.]) + name + keyword.operator.comparative.swift + + control-transfer-statement-keyword + + comment + control-transfer-statement + match + \b(continue|break|fallthrough|return)\b + name + keyword.control.transfer.swift + + custom-operator + + patterns + + + match + (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:]) + name + keyword.operator.custom.prefix.unary.swift + + + match + (?<![\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:\.]) + name + keyword.operator.custom.postfix.unary.swift + + + match + (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?=[\s)\]},;:]) + name + keyword.operator.custom.binary.swift + + + + declaration + + comment + declaration + name + meta.declaration.swift + patterns + + + include + #import-declaration + + + include + #function-declaration + + + + declaration-modifier + + comment + declaration-modifier + match + \b(class|convenience|dynamic|final|lazy|(non)?mutating|optional|override|required|static|unowned((un)?safe)?|weak)\b + name + keyword.other.declaration-modifier.swift + + dictionary-type + + begin + \b(Dictionary)(<) + beginCaptures + + 1 + + name + support.type.dictionary.swift + + 2 + + name + punctuation.dictionary.begin.swift + + + end + (>) + endCaptures + + 1 + + name + punctuation.dictionary.end.swift + + + name + meta.dictionary.swift + patterns + + + include + $self + + + + documentation-comment + + begin + /\*\* + beginCaptures + + 0 + + name + punctuation.definition.comment.block.documentation.begin.swift + + + comment + Documentation comment + end + \*/ + endCaptures + + 0 + + name + punctuation.definition.comment.block.documentation.end.swift + + + name + comment.block.documentation.swift + + floating-point-literal + + name + constant.numeric.floating-point.swift + patterns + + + comment + floating-point-literal -> (decimal-literal)(decimal-fraction)?(decimal-exponent)? + match + \b([0-9][0-9_]*)(\.([0-9][0-9_]*))?([eE][+\-]?([0-9][0-9_]*))?\b + + + comment + floating-point-literal -> (hexadecimal-literal)(hexadecimal-fraction)?(hexadecimal-exponent) + match + \b(0x\h[\h_]*)(\.(0x\h[\h_]*))?([pP][+\-]?(0x\h[\h_]*))\b + + + + function-body + + comment + function-body + name + meta.function-body.swift + patterns + + + include + #code-block + + + + function-declaration + + begin + \b(func)\s+(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B|[/=\-+!*%<>&|\^~.]+)\s*(?=\(|<) + beginCaptures + + 1 + + name + storage.type.function.swift + + 2 + + name + entity.type.function.swift + + + comment + function-declaration + end + (?<=\}) + name + meta.function-declaration.swift + patterns + + + include + #generic-parameter-clause + + + include + #parameter-clause + + + include + #function-result + + + include + #function-body + + + + function-result + + begin + (?<![/=\-+!*%<>&|\^~.])(\->)(?![/=\-+!*%<>&|\^~.])\s* + beginCaptures + + 1 + + name + keyword.operator.function-result.swift + + + comment + function-result + end + \s*(?=\{) + name + meta.function-result.swift + patterns + + + include + #type + + + + generic-parameter-clause + + begin + (<) + beginCaptures + + 1 + + name + punctuation.definition.generic-parameter-clause.begin.swift + + + comment + generic-parameter-clause + end + (>) + endCaptures + + 1 + + name + punctuation.definition.generic-parameter-clause.end.swift + + + name + meta.generic-parameter-clause.swift + patterns + + + include + $self + + + + identifier + + comment + identifier + match + (\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B) + name + meta.identifier.swift + + if-statement-keyword + + comment + if-statement + match + \b(if|else)\b + name + keyword.control.if.swift + + import-declaration + + captures + + 1 + + name + keyword.other.import.swift + + 2 + + name + storage.modifier.swift + + 3 + + name + support.type.module.import.swift + + + comment + import-declaration + 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|[/=\-+!*%<>&|\^~.]+))*) + name + meta.import.swift + + in-line-comment + + captures + + 1 + + name + punctuation.definition.comment.line.double-slash.swift + + + comment + In-line comment + match + (//).* + name + comment.line.double-slash.swift + + increment-decrement-operator + + match + (?<![/=\-+!*%<>&|\^~.])(\+\+|\-\-)(?![/=\-+!*%<>&|\^~.]) + name + keyword.operator.increment-or-decrement.swift + + integer-literal + + name + constant.numeric.integer.swift + patterns + + + comment + binary-literal + match + (\B\-|\b)(0b[01][01_]*)\b + name + constant.numeric.integer.binary.swift + + + comment + octal-literal + match + (\B\-|\b)(0o[0-7][0-7_]*)\b + name + constant.numeric.integer.octal.swift + + + comment + decimal-literal + match + (\B\-|\b)([0-9][0-9_]*)\b + name + constant.numeric.integer.decimal.swift + + + comment + hexadecimal-literal + match + (\B\-|\b)(0x\h[\h_]*)\b + name + constant.numeric.integer.hexadecimal.swift + + + + integer-type + + comment + Int types + match + \bU?Int(8|16|32|64)?\b + name + support.type.swift + + keyword + + patterns + + + include + #branch-statement-keyword + + + include + #control-transfer-statement-keyword + + + include + #loop-statement-keyword + + + include + #catch-statement-keyword + + + include + #operator-declaration-modifier + + + include + #declaration-modifier + + + include + #access-level-modifier + + + comment + declaration keyword + match + \b(class|deinit|enum|extension|func|import|init|let|protocol|static|struct|subscript|typealias|var|throws|rethrows)\b + name + keyword.declaration.swift + + + comment + statement keyword + match + \b(break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|repeat|catch|guard|defer|try|throw)\b + name + keyword.statement.swift + + + comment + expression and type keyword + match + \b(as|dynamicType|is|new|super|self|Self|Type)\b + name + keyword.other.statement.swift + + + comment + other keyword + match + \b(associativity|didSet|get|infix|inout|left|mutating|none|nonmutating|operator|override|postfix|precedence|prefix|right|set|unowned((un)?safe)?|weak|willSet)\b + name + keyword.other.swift + + + + literal + + patterns + + + include + #integer-literal + + + include + #floating-point-literal + + + include + #nil-literal + + + include + #string-literal + + + include + #special-literal + + + + logical-operator + + match + (?<![/=\-+!*%<>&|\^~.])(!|&&|\|\|)(?![/=\-+!*%<>&|\^~.]) + name + keyword.operator.logical.swift + + loop-statement-keyword + + comment + loop-statement + match + \b(while|repeat|for|in)\b + name + keyword.control.loop.swift + + nil-literal + + comment + nil-literal + match + \bnil\b + name + constant.nil.swift + + operator + + patterns + + + include + #comparative-operator + + + include + #assignment-operator + + + include + #logical-operator + + + include + #remainder-operator + + + include + #increment-decrement-operator + + + include + #overflow-operator + + + include + #range-operator + + + include + #bitwise-operator + + + include + #arithmetic-operator + + + include + #ternary-operator + + + include + #type-casting-operator + + + include + #custom-operator + + + + operator-declaration-modifier + + comment + operator-declaration + match + \b(operator|prefix|infix|postfix)\b + name + keyword.other.operator.swift + + optional-type + + beginCaptures + + 1 + + name + support.type.optional.swift + + 2 + + name + punctuation.optional.begin.swift + + + end + (>) + endCaptures + + 1 + + name + punctuation.optional.end.swift + + + match + \b(Optional)(<) + name + meta.optional.swift + patterns + + + include + $self + + + + overflow-operator + + match + (?<![/=\-+!*%<>&|\^~.])\&(\+|\-|\*|\/|%)(?![/=\-+!*%<>&|\^~.]) + name + keyword.operator.overflow.swift + + parameter-clause + + begin + (\() + beginCaptures + + 1 + + name + punctuation.definition.function-arguments.begin.swift + + + comment + parameter-clause + end + (\)) + endCaptures + + 1 + + name + punctuation.definition.function-arguments.end.swift + + + name + meta.parameter-clause.swift + patterns + + + include + $self + + + + primitive-type + + comment + Primitive types + match + \b(Int|Float|Double|String|Bool|Character|Void)\b + name + support.type.swift + + protocol-composition-type + + beginCaptures + + 1 + + name + support.type.protocol.swift + + 2 + + name + punctuation.protocol.begin.swift + + + end + (>) + endCaptures + + 1 + + name + punctuation.protocol.end.swift + + + match + \b(protocol)(<) + name + meta.protocol.swift + patterns + + + include + $self + + + + range-operator + + match + (?<![/=\-+!*%<>&|\^~.])\.\.(?:\.)?(?![/=\-+!*%<>&|\^~.]) + name + keyword.operator.range.swift + + remainder-operator + + match + (?<![/=\-+!*%<>&|\^~.])\%(?![/=\-+!*%<>&|\^~.]) + name + keyword.operator.remainder.swift + + shebang-line + + captures + + 1 + + name + punctuation.definition.comment.line.shebang.swift + + + comment + Shebang line + match + ^(#!).*$ + name + comment.line.shebang.swift + + special-literal + + match + \b__(FILE|LINE|COLUMN|FUNCTION)__\b + name + keyword.other.literal.swift + + storage-type + + match + \b(var|func|let|class|enum|struct|protocol|extension|typealias)\b + name + storage.type.swift + + string-literal + + begin + \" + beginCaptures + + 0 + + name + string.quoted.double.swift + + + end + \" + endCaptures + + 0 + + name + string.quoted.double.swift + + + name + meta.literal.string.swift + patterns + + + match + \\([0tnr\"\'\\]|x\h{2}|u\h{4}|U\h{8}) + name + constant.character.escape.swift + + + begin + (\\\() + beginCaptures + + 1 + + name + support.punctuation.expression.begin.swift + + + contentName + meta.expression.swift + end + (\)) + endCaptures + + 1 + + name + support.punctuation.expression.end.swift + + + patterns + + + include + source.swift + + + + + match + (\"|\\) + name + invalid.illegal.swift + + + match + (.) + name + string.quoted.double.swift + + + + switch-statement-keyword + + comment + switch-statement + match + \b(switch|case|default|where)\b + name + keyword.control.switch.swift + + ternary-operator + + match + (?<=[\s(\[{,;:])(\?|:)(?=[\s)\]},;:]) + name + keyword.operator.ternary.swift + + type + + comment + type + patterns + + + include + #primitive-type + + + include + #integer-type + + + include + #collection-type + + + include + #optional-type + + + include + #protocol-composition-type + + + + type-casting-operator + + match + \b(is\b|as(\?\B|\b)) + name + keyword.operator.type-casting.swift + + + scopeName + source.swift + uuid + 7efa1168-97c3-4433-8dd7-15b99bf3bb53 + + From bdca1c7f0d4082832779ae36d629acca8708c5b2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 16 May 2019 22:33:14 -0700 Subject: [PATCH 2/2] Remove unused files, move syntax and preferences files out of folders Removes JSON-tmLanguage and YAML-tmLanguge files. These files aren't used or recognized by Xi. The .tmPreferences and .tmLangage files were moved into the Swift folder instead of a subfolder. --- .../{Preferences => }/Comments.tmPreferences | 0 .../Swift/{Syntaxes => }/Swift.sublime-syntax | 0 Packages/Swift/Syntaxes/Swift.JSON-tmLanguage | 758 ----------- Packages/Swift/Syntaxes/Swift.YAML-tmLanguage | 441 ------ Packages/Swift/Syntaxes/Swift.tmLanguage | 1199 ----------------- 5 files changed, 2398 deletions(-) rename Packages/Swift/{Preferences => }/Comments.tmPreferences (100%) rename Packages/Swift/{Syntaxes => }/Swift.sublime-syntax (100%) delete mode 100644 Packages/Swift/Syntaxes/Swift.JSON-tmLanguage delete mode 100644 Packages/Swift/Syntaxes/Swift.YAML-tmLanguage delete mode 100644 Packages/Swift/Syntaxes/Swift.tmLanguage diff --git a/Packages/Swift/Preferences/Comments.tmPreferences b/Packages/Swift/Comments.tmPreferences similarity index 100% rename from Packages/Swift/Preferences/Comments.tmPreferences rename to Packages/Swift/Comments.tmPreferences diff --git a/Packages/Swift/Syntaxes/Swift.sublime-syntax b/Packages/Swift/Swift.sublime-syntax similarity index 100% rename from Packages/Swift/Syntaxes/Swift.sublime-syntax rename to Packages/Swift/Swift.sublime-syntax diff --git a/Packages/Swift/Syntaxes/Swift.JSON-tmLanguage b/Packages/Swift/Syntaxes/Swift.JSON-tmLanguage deleted file mode 100644 index 7a83f55..0000000 --- a/Packages/Swift/Syntaxes/Swift.JSON-tmLanguage +++ /dev/null @@ -1,758 +0,0 @@ -{ - "name": "Swift", - "scopeName": "source.swift", - "firstLineMatch": "^#!/.*\\bswift", - "uuid": "7efa1168-97c3-4433-8dd7-15b99bf3bb53", - "repository": { - "custom-operator": { - "patterns": [ - { - "name": "keyword.operator.custom.prefix.unary.swift", - "match": "(?<=[\\s(\\[{,;:])([/=\\-+!*%<>&|\\^~.]++)(?![\\s)\\]},;:])" - }, - { - "name": "keyword.operator.custom.postfix.unary.swift", - "match": "(?&|\\^~.]++)(?![\\s)\\]},;:\\.])" - }, - { - "name": "keyword.operator.custom.binary.swift", - "match": "(?<=[\\s(\\[{,;:])([/=\\-+!*%<>&|\\^~.]++)(?=[\\s)\\]},;:])" - } - ] - }, - "operator-declaration-modifier": { - "comment": "operator-declaration", - "name": "keyword.other.operator.swift", - "match": "\\b(operator|prefix|infix|postfix)\\b" - }, - "if-statement-keyword": { - "comment": "if-statement", - "name": "keyword.control.if.swift", - "match": "\\b(if|else)\\b" - }, - "protocol-composition-type": { - "endCaptures": { - "1": { - "name": "punctuation.protocol.end.swift" - } - }, - "match": "\\b(protocol)(<)", - "beginCaptures": { - "1": { - "name": "support.type.protocol.swift" - }, - "2": { - "name": "punctuation.protocol.begin.swift" - } - }, - "patterns": [ - { - "include": "$self" - } - ], - "end": "(>)", - "name": "meta.protocol.swift" - }, - "overflow-operator": { - "name": "keyword.operator.overflow.swift", - "match": "(?&|\\^~.])\\&(\\+|\\-|\\*|\\/|%)(?![/=\\-+!*%<>&|\\^~.])" - }, - "operator": { - "patterns": [ - { - "include": "#comparative-operator" - }, - { - "include": "#assignment-operator" - }, - { - "include": "#logical-operator" - }, - { - "include": "#remainder-operator" - }, - { - "include": "#increment-decrement-operator" - }, - { - "include": "#overflow-operator" - }, - { - "include": "#range-operator" - }, - { - "include": "#bitwise-operator" - }, - { - "include": "#arithmetic-operator" - }, - { - "include": "#ternary-operator" - }, - { - "include": "#type-casting-operator" - }, - { - "include": "#custom-operator" - } - ] - }, - "type-casting-operator": { - "name": "keyword.operator.type-casting.swift", - "match": "\\b(is\\b|as(\\?\\B|\\b))" - }, - "type": { - "comment": "type", - "patterns": [ - { - "include": "#primitive-type" - }, - { - "include": "#integer-type" - }, - { - "include": "#collection-type" - }, - { - "include": "#optional-type" - }, - { - "include": "#protocol-composition-type" - } - ] - }, - "import-declaration": { - "comment": "import-declaration", - "captures": { - "1": { - "name": "keyword.other.import.swift" - }, - "3": { - "name": "support.type.module.import.swift" - }, - "2": { - "name": "storage.modifier.swift" - } - }, - "name": "meta.import.swift", - "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|[/=\\-+!*%<>&|\\^~.]+))*)" - }, - "string-literal": { - "endCaptures": { - "0": { - "name": "string.quoted.double.swift" - } - }, - "beginCaptures": { - "0": { - "name": "string.quoted.double.swift" - } - }, - "patterns": [ - { - "name": "constant.character.escape.swift", - "match": "\\\\([0tnr\\\"\\'\\\\]|x\\h{2}|u\\h{4}|U\\h{8})" - }, - { - "endCaptures": { - "1": { - "name": "support.punctuation.expression.end.swift" - } - }, - "beginCaptures": { - "1": { - "name": "support.punctuation.expression.begin.swift" - } - }, - "contentName": "meta.expression.swift", - "patterns": [ - { - "include": "source.swift" - } - ], - "begin": "(\\\\\\()", - "end": "(\\))" - }, - { - "name": "invalid.illegal.swift", - "match": "(\\\"|\\\\)" - }, - { - "name": "string.quoted.double.swift", - "match": "(.)" - } - ], - "begin": "\\\"", - "end": "\\\"", - "name": "meta.literal.string.swift" - }, - "nil-literal": { - "comment": "nil-literal", - "name": "constant.nil.swift", - "match": "\\bnil\\b" - }, - "bitwise-operator": { - "name": "keyword.operator.bitwise.swift", - "match": "(?&|\\^~.])(&|\\||\\^|<<|>>)(?![/=\\-+!*%<>&|\\^~.])" - }, - "attribute": { - "comment": "attribute", - "patterns": [ - { - "endCaptures": { - "0": { - "name": "punctuation.definition.attribute-arguments.end.swift" - } - }, - "beginCaptures": { - "1": { - "name": "storage.modifier.attribute.swift" - }, - "3": { - "name": "punctuation.definition.attribute-arguments.begin.swift" - }, - "2": { - "name": "punctuation.definition.attribute.swift" - } - }, - "contentName": "meta.attribute.arguments.swift", - "patterns": [ - { - "include": "$self" - } - ], - "begin": "((@)(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B))(\\()", - "end": "\\)" - }, - { - "captures": { - "1": { - "name": "storage.modifier.attribute.swift" - }, - "2": { - "name": "punctuation.definition.attribute.swift" - } - }, - "match": "((@)(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B))" - } - ], - "name": "meta.attribute.swift" - }, - "loop-statement-keyword": { - "comment": "loop-statement", - "name": "keyword.control.loop.swift", - "match": "\\b(while|repeat|for|in)\\b" - }, - "dictionary-type": { - "endCaptures": { - "1": { - "name": "punctuation.dictionary.end.swift" - } - }, - "beginCaptures": { - "1": { - "name": "support.type.dictionary.swift" - }, - "2": { - "name": "punctuation.dictionary.begin.swift" - } - }, - "patterns": [ - { - "include": "$self" - } - ], - "begin": "\\b(Dictionary)(<)", - "end": "(>)", - "name": "meta.dictionary.swift" - }, - "parameter-clause": { - "endCaptures": { - "1": { - "name": "punctuation.definition.function-arguments.end.swift" - } - }, - "beginCaptures": { - "1": { - "name": "punctuation.definition.function-arguments.begin.swift" - } - }, - "comment": "parameter-clause", - "patterns": [ - { - "include": "$self" - } - ], - "begin": "(\\()", - "end": "(\\))", - "name": "meta.parameter-clause.swift" - }, - "comment": { - "comment": "All comment types", - "patterns": [ - { - "include": "#documentation-comment" - }, - { - "include": "#block-comment" - }, - { - "include": "#in-line-comment" - } - ] - }, - "special-literal": { - "name": "keyword.other.literal.swift", - "match": "\\b__(FILE|LINE|COLUMN|FUNCTION)__\\b" - }, - "array-type": { - "endCaptures": { - "1": { - "name": "punctuation.array.end.swift" - } - }, - "beginCaptures": { - "1": { - "name": "support.type.array.swift" - }, - "2": { - "name": "punctuation.array.begin.swift" - } - }, - "patterns": [ - { - "include": "$self" - } - ], - "begin": "\\b(Array)(<)", - "end": "(>)", - "name": "meta.array.swift" - }, - "integer-type": { - "comment": "Int types", - "name": "support.type.swift", - "match": "\\bU?Int(8|16|32|64)?\\b" - }, - "function-declaration": { - "beginCaptures": { - "1": { - "name": "storage.type.function.swift" - }, - "2": { - "name": "entity.type.function.swift" - } - }, - "comment": "function-declaration", - "patterns": [ - { - "include": "#generic-parameter-clause" - }, - { - "include": "#parameter-clause" - }, - { - "include": "#function-result" - }, - { - "include": "#function-body" - } - ], - "begin": "\\b(func)\\s+(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B|[/=\\-+!*%<>&|\\^~.]+)\\s*(?=\\(|<)", - "end": "(?<=\\})", - "name": "meta.function-declaration.swift" - }, - "code-block": { - "endCaptures": { - "1": { - "name": "punctuation.definition.code-block.end.swift" - } - }, - "beginCaptures": { - "1": { - "name": "punctuation.definition.code-block.begin.swift" - } - }, - "comment": "code-block", - "patterns": [ - { - "include": "$self" - } - ], - "begin": "(\\{)", - "end": "(\\})" - }, - "identifier": { - "comment": "identifier", - "name": "meta.identifier.swift", - "match": "(\\B\\$[0-9]+|\\b[\\w^\\d][\\w\\d]*\\b|\\B`[\\w^\\d][\\w\\d]*`\\B)" - }, - "ternary-operator": { - "name": "keyword.operator.ternary.swift", - "match": "(?<=[\\s(\\[{,;:])(\\?|:)(?=[\\s)\\]},;:])" - }, - "function-body": { - "comment": "function-body", - "patterns": [ - { - "include": "#code-block" - } - ], - "name": "meta.function-body.swift" - }, - "control-transfer-statement-keyword": { - "comment": "control-transfer-statement", - "name": "keyword.control.transfer.swift", - "match": "\\b(continue|break|fallthrough|return)\\b" - }, - "boolean": { - "name": "keyword.constant.boolean.swift", - "match": "\\b(true|false)\\b" - }, - "optional-type": { - "endCaptures": { - "1": { - "name": "punctuation.optional.end.swift" - } - }, - "match": "\\b(Optional)(<)", - "beginCaptures": { - "1": { - "name": "support.type.optional.swift" - }, - "2": { - "name": "punctuation.optional.begin.swift" - } - }, - "patterns": [ - { - "include": "$self" - } - ], - "end": "(>)", - "name": "meta.optional.swift" - }, - "arithmetic-operator": { - "name": "keyword.operator.arithmetic.swift", - "match": "(?&|\\^~.])(\\+|\\-|\\*|\\/)(?![/=\\-+!*%<>&|\\^~.])" - }, - "logical-operator": { - "name": "keyword.operator.logical.swift", - "match": "(?&|\\^~.])(!|&&|\\|\\|)(?![/=\\-+!*%<>&|\\^~.])" - }, - "declaration": { - "comment": "declaration", - "patterns": [ - { - "include": "#import-declaration" - }, - { - "include": "#function-declaration" - } - ], - "name": "meta.declaration.swift" - }, - "increment-decrement-operator": { - "name": "keyword.operator.increment-or-decrement.swift", - "match": "(?&|\\^~.])(\\+\\+|\\-\\-)(?![/=\\-+!*%<>&|\\^~.])" - }, - "access-level-modifier": { - "comment": "access-level-modifier", - "name": "keyword.other.access-level-modifier.swift", - "match": "\\b(open|public|internal|fileprivate|private)\\b(?:\\(set\\))?" - }, - "branch-statement-keyword": { - "patterns": [ - { - "include": "#if-statement-keyword" - }, - { - "include": "#switch-statement-keyword" - } - ], - "name": "keyword.control.branch.swift" - }, - "declaration-modifier": { - "comment": "declaration-modifier", - "name": "keyword.other.declaration-modifier.swift", - "match": "\\b(class|convenience|dynamic|final|lazy|(non)?mutating|optional|override|required|static|unowned((un)?safe)?|weak)\\b" - }, - "keyword": { - "patterns": [ - { - "include": "#branch-statement-keyword" - }, - { - "include": "#control-transfer-statement-keyword" - }, - { - "include": "#loop-statement-keyword" - }, - { - "include": "#catch-statement-keyword" - }, - { - "include": "#operator-declaration-modifier" - }, - { - "include": "#declaration-modifier" - }, - { - "include": "#access-level-modifier" - }, - { - "comment": "declaration keyword", - "name": "keyword.declaration.swift", - "match": "\\b(class|deinit|enum|extension|func|import|init|let|protocol|static|struct|subscript|typealias|var|throws|rethrows)\\b" - }, - { - "comment": "statement keyword", - "name": "keyword.statement.swift", - "match": "\\b(break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|repeat|catch|guard|defer|try|throw)\\b" - }, - { - "comment": "expression and type keyword", - "name": "keyword.other.statement.swift", - "match": "\\b(as|dynamicType|is|new|super|self|Self|Type)\\b" - }, - { - "comment": "other keyword", - "name": "keyword.other.swift", - "match": "\\b(associativity|didSet|get|infix|inout|left|mutating|none|nonmutating|operator|override|postfix|precedence|prefix|right|set|unowned((un)?safe)?|weak|willSet)\\b" - } - ] - }, - "catch-statement-keyword": { - "comment": "catch-statement", - "name": "kewyord.control.catch.swift", - "match": "\\b(catch|do)\\b" - }, - "generic-parameter-clause": { - "endCaptures": { - "1": { - "name": "punctuation.definition.generic-parameter-clause.end.swift" - } - }, - "beginCaptures": { - "1": { - "name": "punctuation.definition.generic-parameter-clause.begin.swift" - } - }, - "comment": "generic-parameter-clause", - "patterns": [ - { - "include": "$self" - } - ], - "begin": "(<)", - "end": "(>)", - "name": "meta.generic-parameter-clause.swift" - }, - "comparative-operator": { - "name": "keyword.operator.comparative.swift", - "match": "(?&|\\^~.])((=|!)==?|(<|>)=?|~=)(?![/=\\-+!*%<>&|\\^~.])" - }, - "literal": { - "patterns": [ - { - "include": "#integer-literal" - }, - { - "include": "#floating-point-literal" - }, - { - "include": "#nil-literal" - }, - { - "include": "#string-literal" - }, - { - "include": "#special-literal" - } - ] - }, - "in-line-comment": { - "comment": "In-line comment", - "captures": { - "1": { - "name": "punctuation.definition.comment.line.double-slash.swift" - } - }, - "name": "comment.line.double-slash.swift", - "match": "(//).*" - }, - "storage-type": { - "name": "storage.type.swift", - "match": "\\b(var|func|let|class|enum|struct|protocol|extension|typealias)\\b" - }, - "primitive-type": { - "comment": "Primitive types", - "name": "support.type.swift", - "match": "\\b(Int|Float|Double|String|Bool|Character|Void)\\b" - }, - "shebang-line": { - "comment": "Shebang line", - "captures": { - "1": { - "name": "punctuation.definition.comment.line.shebang.swift" - } - }, - "name": "comment.line.shebang.swift", - "match": "^(#!).*$" - }, - "function-result": { - "beginCaptures": { - "1": { - "name": "keyword.operator.function-result.swift" - } - }, - "comment": "function-result", - "patterns": [ - { - "include": "#type" - } - ], - "begin": "(?&|\\^~.])(\\->)(?![/=\\-+!*%<>&|\\^~.])\\s*", - "end": "\\s*(?=\\{)", - "name": "meta.function-result.swift" - }, - "floating-point-literal": { - "patterns": [ - { - "comment": "floating-point-literal -> (decimal-literal)(decimal-fraction)?(decimal-exponent)?", - "match": "\\b([0-9][0-9_]*)(\\.([0-9][0-9_]*))?([eE][+\\-]?([0-9][0-9_]*))?\\b" - }, - { - "comment": "floating-point-literal -> (hexadecimal-literal)(hexadecimal-fraction)?(hexadecimal-exponent)", - "match": "\\b(0x\\h[\\h_]*)(\\.(0x\\h[\\h_]*))?([pP][+\\-]?(0x\\h[\\h_]*))\\b" - } - ], - "name": "constant.numeric.floating-point.swift" - }, - "collection-type": { - "comment": "Collection types", - "patterns": [ - { - "include": "#array-type" - }, - { - "include": "#dictionary-type" - }, - { - "name": "support.type.swift", - "match": "\\b(Array|Dictionary)\\b" - } - ] - }, - "assignment-operator": { - "name": "keyword.operator.assignment.swift", - "match": "(?&|\\^~.])(\\+|\\-|\\*|\\/|%|<<|>>|&|\\^|\\||&&|\\|\\|)?=(?![/=\\-+!*%<>&|\\^~.])" - }, - "block-comment": { - "endCaptures": { - "0": { - "name": "punctuation.definition.comment.block.end.swift" - } - }, - "beginCaptures": { - "0": { - "name": "punctuation.definition.comment.block.begin.swift" - } - }, - "comment": "Block comment", - "begin": "/\\*", - "end": "\\*/", - "name": "comment.block.swift" - }, - "switch-statement-keyword": { - "comment": "switch-statement", - "name": "keyword.control.switch.swift", - "match": "\\b(switch|case|default|where)\\b" - }, - "remainder-operator": { - "name": "keyword.operator.remainder.swift", - "match": "(?&|\\^~.])\\%(?![/=\\-+!*%<>&|\\^~.])" - }, - "documentation-comment": { - "endCaptures": { - "0": { - "name": "punctuation.definition.comment.block.documentation.end.swift" - } - }, - "beginCaptures": { - "0": { - "name": "punctuation.definition.comment.block.documentation.begin.swift" - } - }, - "comment": "Documentation comment", - "begin": "/\\*\\*", - "end": "\\*/", - "name": "comment.block.documentation.swift" - }, - "integer-literal": { - "patterns": [ - { - "comment": "binary-literal", - "name": "constant.numeric.integer.binary.swift", - "match": "(\\B\\-|\\b)(0b[01][01_]*)\\b" - }, - { - "comment": "octal-literal", - "name": "constant.numeric.integer.octal.swift", - "match": "(\\B\\-|\\b)(0o[0-7][0-7_]*)\\b" - }, - { - "comment": "decimal-literal", - "name": "constant.numeric.integer.decimal.swift", - "match": "(\\B\\-|\\b)([0-9][0-9_]*)\\b" - }, - { - "comment": "hexadecimal-literal", - "name": "constant.numeric.integer.hexadecimal.swift", - "match": "(\\B\\-|\\b)(0x\\h[\\h_]*)\\b" - } - ], - "name": "constant.numeric.integer.swift" - }, - "range-operator": { - "name": "keyword.operator.range.swift", - "match": "(?&|\\^~.])\\.\\.(?:\\.)?(?![/=\\-+!*%<>&|\\^~.])" - } - }, - "author": "Matt Alexander - matt@queg.net", - "keyEquivalent": "^~S", - "fileTypes": [ - "swift" - ], - "patterns": [ - { - "include": "#shebang-line" - }, - { - "include": "#comment" - }, - { - "include": "#attribute" - }, - { - "include": "#literal" - }, - { - "include": "#operator" - }, - { - "include": "#declaration" - }, - { - "include": "#storage-type" - }, - { - "include": "#keyword" - }, - { - "include": "#type" - }, - { - "include": "#boolean" - } - ] -} diff --git a/Packages/Swift/Syntaxes/Swift.YAML-tmLanguage b/Packages/Swift/Syntaxes/Swift.YAML-tmLanguage deleted file mode 100644 index e3003b0..0000000 --- a/Packages/Swift/Syntaxes/Swift.YAML-tmLanguage +++ /dev/null @@ -1,441 +0,0 @@ -# author: Matt Alexander - matt@queg.net -# [PackageDev] target_format: plist, source_format: yaml, ext: tmLanguage -# [PackageDev] target_format: json, source_format: yaml, ext: JSON-tmLanguage ---- -name: Swift -scopeName: source.swift -author: Matt Alexander - matt@queg.net -fileTypes: [swift] -uuid: 7efa1168-97c3-4433-8dd7-15b99bf3bb53 -keyEquivalent: ^~S -firstLineMatch: ^#!/.*\bswift - -patterns: -- include: '#shebang-line' -- include: '#comment' -- include: '#attribute' -- include: '#literal' -- include: '#operator' -- include: '#declaration' -- include: '#storage-type' -- include: '#keyword' -- include: '#type' -- include: '#boolean' - -repository: - -# Identifier - identifier: - comment: identifier - name: meta.identifier.swift - match: (\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B) - - -# Keywords - keyword: - patterns: - - include: '#branch-statement-keyword' - - include: '#control-transfer-statement-keyword' - - include: '#loop-statement-keyword' - - include: '#catch-statement-keyword' - - include: '#operator-declaration-modifier' - - include: '#declaration-modifier' - - include: '#access-level-modifier' - - comment: declaration keyword - name: keyword.declaration.swift - match: \b(class|deinit|enum|extension|func|import|init|let|protocol|static|struct|subscript|typealias|var|throws|rethrows)\b - - comment: statement keyword - name: keyword.statement.swift - match: \b(break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|repeat|catch|guard|defer|try|throw)\b - - comment: expression and type keyword - name: keyword.other.statement.swift - match: \b(as|dynamicType|is|new|super|self|Self|Type)\b - - comment: other keyword - name: keyword.other.swift - match: \b(associativity|didSet|get|infix|inout|left|mutating|none|nonmutating|operator|override|postfix|precedence|prefix|right|set|unowned((un)?safe)?|weak|willSet)\b - branch-statement-keyword: - name: keyword.control.branch.swift - patterns: - - include: '#if-statement-keyword' - - include: '#switch-statement-keyword' - switch-statement-keyword: - comment: switch-statement - name: keyword.control.switch.swift - match: \b(switch|case|default|where)\b - if-statement-keyword: - comment: if-statement - name: keyword.control.if.swift - match: \b(if|else)\b - control-transfer-statement-keyword: - comment: control-transfer-statement - name: keyword.control.transfer.swift - match: \b(continue|break|fallthrough|return)\b - loop-statement-keyword: - comment: loop-statement - name: keyword.control.loop.swift - match: \b(while|repeat|for|in)\b - catch-statement-keyword: - comment: catch-statement - name: kewyord.control.catch.swift - match: \b(catch|do)\b - operator-declaration-modifier: - comment: operator-declaration - name: keyword.other.operator.swift - match: \b(operator|prefix|infix|postfix)\b - access-level-modifier: - comment: access-level-modifier - name: keyword.other.access-level-modifier.swift - match: \b(open|public|internal|fileprivate|private)\b(?:\(set\))? - declaration-modifier: - comment: declaration-modifier - name: keyword.other.declaration-modifier.swift - match: \b(class|convenience|dynamic|final|lazy|(non)?mutating|optional|override|required|static|unowned((un)?safe)?|weak)\b - - -# Storage types - storage-type: - name: storage.type.swift - match: \b(var|func|let|class|enum|struct|protocol|extension|typealias)\b - - -# Operators - operator: - patterns: - - include: '#comparative-operator' - - include: '#assignment-operator' - - include: '#logical-operator' - - include: '#remainder-operator' - - include: '#increment-decrement-operator' - - include: '#overflow-operator' - - include: '#range-operator' - - include: '#bitwise-operator' - - include: '#arithmetic-operator' - - include: '#ternary-operator' - - include: '#type-casting-operator' - - include: '#custom-operator' - comparative-operator: - name: keyword.operator.comparative.swift - match: (?&|\^~.])((=|!)==?|(<|>)=?|~=)(?![/=\-+!*%<>&|\^~.]) - assignment-operator: - name: keyword.operator.assignment.swift - match: (?&|\^~.])(\+|\-|\*|\/|%|<<|>>|&|\^|\||&&|\|\|)?=(?![/=\-+!*%<>&|\^~.]) - logical-operator: - name: keyword.operator.logical.swift - match: (?&|\^~.])(!|&&|\|\|)(?![/=\-+!*%<>&|\^~.]) - remainder-operator: - name: keyword.operator.remainder.swift - match: (?&|\^~.])\%(?![/=\-+!*%<>&|\^~.]) - increment-decrement-operator: - name: keyword.operator.increment-or-decrement.swift - match: (?&|\^~.])(\+\+|\-\-)(?![/=\-+!*%<>&|\^~.]) - overflow-operator: - name: keyword.operator.overflow.swift - match: (?&|\^~.])\&(\+|\-|\*|\/|%)(?![/=\-+!*%<>&|\^~.]) - range-operator: - name: keyword.operator.range.swift - match: (?&|\^~.])\.\.(?:\.)?(?![/=\-+!*%<>&|\^~.]) - arithmetic-operator: - name: keyword.operator.arithmetic.swift - match: (?&|\^~.])(\+|\-|\*|\/)(?![/=\-+!*%<>&|\^~.]) - bitwise-operator: - name: keyword.operator.bitwise.swift - match: (?&|\^~.])(&|\||\^|<<|>>)(?![/=\-+!*%<>&|\^~.]) - ternary-operator: - name: keyword.operator.ternary.swift - match: (?<=[\s(\[{,;:])(\?|:)(?=[\s)\]},;:]) - type-casting-operator: - name: keyword.operator.type-casting.swift - match: \b(is\b|as(\?\B|\b)) - custom-operator: - patterns: - - name: keyword.operator.custom.prefix.unary.swift - match: (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:]) - - name: keyword.operator.custom.postfix.unary.swift - match: (?&|\^~.]++)(?![\s)\]},;:\.]) - - name: keyword.operator.custom.binary.swift - match: (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?=[\s)\]},;:]) - - -# Literal Expressions - literal: - patterns: - - include: '#integer-literal' - - include: '#floating-point-literal' - - include: '#nil-literal' - - include: '#string-literal' - - include: '#special-literal' - integer-literal: - name: constant.numeric.integer.swift - patterns: - - comment: binary-literal - name: constant.numeric.integer.binary.swift - match: (\B\-|\b)(0b[01][01_]*)\b - - comment: octal-literal - name: constant.numeric.integer.octal.swift - match: (\B\-|\b)(0o[0-7][0-7_]*)\b - - comment: decimal-literal - name: constant.numeric.integer.decimal.swift - match: (\B\-|\b)([0-9][0-9_]*)\b - - comment: hexadecimal-literal - name: constant.numeric.integer.hexadecimal.swift - match: (\B\-|\b)(0x\h[\h_]*)\b - floating-point-literal: - name: constant.numeric.floating-point.swift - patterns: - - comment: floating-point-literal -> (decimal-literal)(decimal-fraction)?(decimal-exponent)? - match: \b([0-9][0-9_]*)(\.([0-9][0-9_]*))?([eE][+\-]?([0-9][0-9_]*))?\b - - comment: floating-point-literal -> (hexadecimal-literal)(hexadecimal-fraction)?(hexadecimal-exponent) - match: \b(0x\h[\h_]*)(\.(0x\h[\h_]*))?([pP][+\-]?(0x\h[\h_]*))\b - nil-literal: - comment: nil-literal - name: constant.nil.swift - match: \bnil\b - string-literal: - name: meta.literal.string.swift - begin: \" - end: \" - beginCaptures: - '0': { name: string.quoted.double.swift } - endCaptures: - '0': { name: string.quoted.double.swift } - patterns: - - name: constant.character.escape.swift - match: \\([0tnr\"\'\\]|x\h{2}|u\h{4}|U\h{8}) - - contentName: meta.expression.swift - begin: (\\\() - end: (\)) - beginCaptures: - '1': { name: support.punctuation.expression.begin.swift } - endCaptures: - '1': { name: support.punctuation.expression.end.swift } - patterns: - - include: source.swift - - name: invalid.illegal.swift - match: (\"|\\) - - name: string.quoted.double.swift - match: (.) - special-literal: - name: keyword.other.literal.swift - match: \b__(FILE|LINE|COLUMN|FUNCTION)__\b - - -# Primitive values - boolean: - name: keyword.constant.boolean.swift - match: \b(true|false)\b - - -# Type names - type: - comment: type - patterns: - - include: '#primitive-type' - - include: '#integer-type' - - include: '#collection-type' - - include: '#optional-type' - - include: '#protocol-composition-type' - primitive-type: - comment: Primitive types - name: support.type.swift - match: \b(Int|Float|Double|String|Bool|Character|Void)\b - integer-type: - comment: Int types - name: support.type.swift - match: \bU?Int(8|16|32|64)?\b - collection-type: - comment: Collection types - patterns: - - include: '#array-type' - - include: '#dictionary-type' - - name: support.type.swift - match: \b(Array|Dictionary)\b - array-type: - name: meta.array.swift - begin: \b(Array)(<) - end: (>) - beginCaptures: - '1': { name: support.type.array.swift } - '2': { name: punctuation.array.begin.swift } - endCaptures: - '1': {name: punctuation.array.end.swift} - patterns: - - include: $self - dictionary-type: - name: meta.dictionary.swift - begin: \b(Dictionary)(<) - end: (>) - beginCaptures: - '1': { name: support.type.dictionary.swift } - '2': { name: punctuation.dictionary.begin.swift } - endCaptures: - '1': {name: punctuation.dictionary.end.swift} - patterns: - - include: $self - optional-type: - name: meta.optional.swift - match: \b(Optional)(<) - end: (>) - beginCaptures: - '1': { name: support.type.optional.swift } - '2': { name: punctuation.optional.begin.swift } - endCaptures: - '1': { name: punctuation.optional.end.swift } - patterns: - - include: $self - protocol-composition-type: - name: meta.protocol.swift - match: \b(protocol)(<) - end: (>) - beginCaptures: - '1': { name: support.type.protocol.swift } - '2': { name: punctuation.protocol.begin.swift } - endCaptures: - '1': { name: punctuation.protocol.end.swift } - patterns: - - include: $self - -# Attributes - attribute: - comment: attribute - name: meta.attribute.swift - patterns: - - begin: ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B))(\() - end: \) - contentName: meta.attribute.arguments.swift - beginCaptures: - '1': { name: storage.modifier.attribute.swift } - '2': { name: punctuation.definition.attribute.swift } - '3': { name: punctuation.definition.attribute-arguments.begin.swift } - endCaptures: - '0': { name: punctuation.definition.attribute-arguments.end.swift } - patterns: - - include: $self - - match: ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B)) - captures: - '1': { name: storage.modifier.attribute.swift } - '2': { name: punctuation.definition.attribute.swift } - - -# Declarations - declaration: - comment: declaration - name: meta.declaration.swift - patterns: - - include: '#import-declaration' - - include: '#function-declaration' - -# Import Declaration - import-declaration: - comment: import-declaration - name: meta.import.swift - 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|[/=\-+!*%<>&|\^~.]+))*) - captures: - '1': { name: keyword.other.import.swift } - '2': { name: storage.modifier.swift } - '3': { name: support.type.module.import.swift } - -# Function Declaration - function-declaration: - comment: function-declaration - name: meta.function-declaration.swift - begin: \b(func)\s+(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B|[/=\-+!*%<>&|\^~.]+)\s*(?=\(|<) - end: (?<=\}) - beginCaptures: - '1': { name: storage.type.function.swift } - '2': { name: entity.type.function.swift } - patterns: - - include: '#generic-parameter-clause' - - include: '#parameter-clause' - - include: '#function-result' - - include: '#function-body' - parameter-clause: - comment: parameter-clause - name: meta.parameter-clause.swift - begin: (\() - end: (\)) - beginCaptures: - '1': { name: punctuation.definition.function-arguments.begin.swift } - endCaptures: - '1': { name: punctuation.definition.function-arguments.end.swift } - patterns: - - include: $self - function-result: - comment: function-result - name: meta.function-result.swift - begin: (?&|\^~.])(\->)(?![/=\-+!*%<>&|\^~.])\s* - end: \s*(?=\{) - beginCaptures: - '1': { name: keyword.operator.function-result.swift } - patterns: - - include: '#type' - function-body: - comment: function-body - name: meta.function-body.swift - patterns: - - include: '#code-block' - - - generic-parameter-clause: - comment: generic-parameter-clause - name: meta.generic-parameter-clause.swift - begin: (<) - end: (>) - beginCaptures: - '1': { name: punctuation.definition.generic-parameter-clause.begin.swift } - endCaptures: - '1': { name: punctuation.definition.generic-parameter-clause.end.swift } - patterns: - - include: $self - - code-block: - comment: code-block - begin: (\{) - end: (\}) - beginCaptures: - '1': { name: punctuation.definition.code-block.begin.swift } - endCaptures: - '1': { name: punctuation.definition.code-block.end.swift } - patterns: - - include: $self - - -# Comments - comment: - comment: All comment types - patterns: - - include: '#documentation-comment' - - include: '#block-comment' - - include: '#in-line-comment' - documentation-comment: - comment: Documentation comment - name: comment.block.documentation.swift - begin: /\*\* - end: \*/ - beginCaptures: - '0': { name: punctuation.definition.comment.block.documentation.begin.swift } - endCaptures: - '0': { name: punctuation.definition.comment.block.documentation.end.swift } - block-comment: - comment: Block comment - name: comment.block.swift - begin: /\* - end: \*/ - beginCaptures: - '0': { name: punctuation.definition.comment.block.begin.swift } - endCaptures: - '0': { name: punctuation.definition.comment.block.end.swift } - in-line-comment: - comment: In-line comment - name: comment.line.double-slash.swift - match: (//).* - captures: - '1': { name: punctuation.definition.comment.line.double-slash.swift } - - shebang-line: - comment: Shebang line - name: comment.line.shebang.swift - match: ^(#!).*$ - captures: - '1': { name: punctuation.definition.comment.line.shebang.swift } - -... diff --git a/Packages/Swift/Syntaxes/Swift.tmLanguage b/Packages/Swift/Syntaxes/Swift.tmLanguage deleted file mode 100644 index 9993e0e..0000000 --- a/Packages/Swift/Syntaxes/Swift.tmLanguage +++ /dev/null @@ -1,1199 +0,0 @@ - - - - - author - Matt Alexander - matt@queg.net - fileTypes - - swift - - firstLineMatch - ^#!/.*\bswift - keyEquivalent - ^~S - name - Swift - patterns - - - include - #shebang-line - - - include - #comment - - - include - #attribute - - - include - #literal - - - include - #operator - - - include - #declaration - - - include - #storage-type - - - include - #keyword - - - include - #type - - - include - #boolean - - - repository - - access-level-modifier - - comment - access-level-modifier - match - \b(open|public|internal|fileprivate|private)\b(?:\(set\))? - name - keyword.other.access-level-modifier.swift - - arithmetic-operator - - match - (?<![/=\-+!*%<>&|\^~.])(\+|\-|\*|\/)(?![/=\-+!*%<>&|\^~.]) - name - keyword.operator.arithmetic.swift - - array-type - - begin - \b(Array)(<) - beginCaptures - - 1 - - name - support.type.array.swift - - 2 - - name - punctuation.array.begin.swift - - - end - (>) - endCaptures - - 1 - - name - punctuation.array.end.swift - - - name - meta.array.swift - patterns - - - include - $self - - - - assignment-operator - - match - (?<![/=\-+!*%<>&|\^~.])(\+|\-|\*|\/|%|<<|>>|&|\^|\||&&|\|\|)?=(?![/=\-+!*%<>&|\^~.]) - name - keyword.operator.assignment.swift - - attribute - - comment - attribute - name - meta.attribute.swift - patterns - - - begin - ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B))(\() - beginCaptures - - 1 - - name - storage.modifier.attribute.swift - - 2 - - name - punctuation.definition.attribute.swift - - 3 - - name - punctuation.definition.attribute-arguments.begin.swift - - - contentName - meta.attribute.arguments.swift - end - \) - endCaptures - - 0 - - name - punctuation.definition.attribute-arguments.end.swift - - - patterns - - - include - $self - - - - - captures - - 1 - - name - storage.modifier.attribute.swift - - 2 - - name - punctuation.definition.attribute.swift - - - match - ((@)(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B)) - - - - bitwise-operator - - match - (?<![/=\-+!*%<>&|\^~.])(&|\||\^|<<|>>)(?![/=\-+!*%<>&|\^~.]) - name - keyword.operator.bitwise.swift - - block-comment - - begin - /\* - beginCaptures - - 0 - - name - punctuation.definition.comment.block.begin.swift - - - comment - Block comment - end - \*/ - endCaptures - - 0 - - name - punctuation.definition.comment.block.end.swift - - - name - comment.block.swift - - boolean - - match - \b(true|false)\b - name - keyword.constant.boolean.swift - - branch-statement-keyword - - name - keyword.control.branch.swift - patterns - - - include - #if-statement-keyword - - - include - #switch-statement-keyword - - - - catch-statement-keyword - - comment - catch-statement - match - \b(catch|do)\b - name - kewyord.control.catch.swift - - code-block - - begin - (\{) - beginCaptures - - 1 - - name - punctuation.definition.code-block.begin.swift - - - comment - code-block - end - (\}) - endCaptures - - 1 - - name - punctuation.definition.code-block.end.swift - - - patterns - - - include - $self - - - - collection-type - - comment - Collection types - patterns - - - include - #array-type - - - include - #dictionary-type - - - match - \b(Array|Dictionary)\b - name - support.type.swift - - - - comment - - comment - All comment types - patterns - - - include - #documentation-comment - - - include - #block-comment - - - include - #in-line-comment - - - - comparative-operator - - match - (?<![/=\-+!*%<>&|\^~.])((=|!)==?|(<|>)=?|~=)(?![/=\-+!*%<>&|\^~.]) - name - keyword.operator.comparative.swift - - control-transfer-statement-keyword - - comment - control-transfer-statement - match - \b(continue|break|fallthrough|return)\b - name - keyword.control.transfer.swift - - custom-operator - - patterns - - - match - (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:]) - name - keyword.operator.custom.prefix.unary.swift - - - match - (?<![\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?![\s)\]},;:\.]) - name - keyword.operator.custom.postfix.unary.swift - - - match - (?<=[\s(\[{,;:])([/=\-+!*%<>&|\^~.]++)(?=[\s)\]},;:]) - name - keyword.operator.custom.binary.swift - - - - declaration - - comment - declaration - name - meta.declaration.swift - patterns - - - include - #import-declaration - - - include - #function-declaration - - - - declaration-modifier - - comment - declaration-modifier - match - \b(class|convenience|dynamic|final|lazy|(non)?mutating|optional|override|required|static|unowned((un)?safe)?|weak)\b - name - keyword.other.declaration-modifier.swift - - dictionary-type - - begin - \b(Dictionary)(<) - beginCaptures - - 1 - - name - support.type.dictionary.swift - - 2 - - name - punctuation.dictionary.begin.swift - - - end - (>) - endCaptures - - 1 - - name - punctuation.dictionary.end.swift - - - name - meta.dictionary.swift - patterns - - - include - $self - - - - documentation-comment - - begin - /\*\* - beginCaptures - - 0 - - name - punctuation.definition.comment.block.documentation.begin.swift - - - comment - Documentation comment - end - \*/ - endCaptures - - 0 - - name - punctuation.definition.comment.block.documentation.end.swift - - - name - comment.block.documentation.swift - - floating-point-literal - - name - constant.numeric.floating-point.swift - patterns - - - comment - floating-point-literal -> (decimal-literal)(decimal-fraction)?(decimal-exponent)? - match - \b([0-9][0-9_]*)(\.([0-9][0-9_]*))?([eE][+\-]?([0-9][0-9_]*))?\b - - - comment - floating-point-literal -> (hexadecimal-literal)(hexadecimal-fraction)?(hexadecimal-exponent) - match - \b(0x\h[\h_]*)(\.(0x\h[\h_]*))?([pP][+\-]?(0x\h[\h_]*))\b - - - - function-body - - comment - function-body - name - meta.function-body.swift - patterns - - - include - #code-block - - - - function-declaration - - begin - \b(func)\s+(\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B|[/=\-+!*%<>&|\^~.]+)\s*(?=\(|<) - beginCaptures - - 1 - - name - storage.type.function.swift - - 2 - - name - entity.type.function.swift - - - comment - function-declaration - end - (?<=\}) - name - meta.function-declaration.swift - patterns - - - include - #generic-parameter-clause - - - include - #parameter-clause - - - include - #function-result - - - include - #function-body - - - - function-result - - begin - (?<![/=\-+!*%<>&|\^~.])(\->)(?![/=\-+!*%<>&|\^~.])\s* - beginCaptures - - 1 - - name - keyword.operator.function-result.swift - - - comment - function-result - end - \s*(?=\{) - name - meta.function-result.swift - patterns - - - include - #type - - - - generic-parameter-clause - - begin - (<) - beginCaptures - - 1 - - name - punctuation.definition.generic-parameter-clause.begin.swift - - - comment - generic-parameter-clause - end - (>) - endCaptures - - 1 - - name - punctuation.definition.generic-parameter-clause.end.swift - - - name - meta.generic-parameter-clause.swift - patterns - - - include - $self - - - - identifier - - comment - identifier - match - (\B\$[0-9]+|\b[\w^\d][\w\d]*\b|\B`[\w^\d][\w\d]*`\B) - name - meta.identifier.swift - - if-statement-keyword - - comment - if-statement - match - \b(if|else)\b - name - keyword.control.if.swift - - import-declaration - - captures - - 1 - - name - keyword.other.import.swift - - 2 - - name - storage.modifier.swift - - 3 - - name - support.type.module.import.swift - - - comment - import-declaration - 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|[/=\-+!*%<>&|\^~.]+))*) - name - meta.import.swift - - in-line-comment - - captures - - 1 - - name - punctuation.definition.comment.line.double-slash.swift - - - comment - In-line comment - match - (//).* - name - comment.line.double-slash.swift - - increment-decrement-operator - - match - (?<![/=\-+!*%<>&|\^~.])(\+\+|\-\-)(?![/=\-+!*%<>&|\^~.]) - name - keyword.operator.increment-or-decrement.swift - - integer-literal - - name - constant.numeric.integer.swift - patterns - - - comment - binary-literal - match - (\B\-|\b)(0b[01][01_]*)\b - name - constant.numeric.integer.binary.swift - - - comment - octal-literal - match - (\B\-|\b)(0o[0-7][0-7_]*)\b - name - constant.numeric.integer.octal.swift - - - comment - decimal-literal - match - (\B\-|\b)([0-9][0-9_]*)\b - name - constant.numeric.integer.decimal.swift - - - comment - hexadecimal-literal - match - (\B\-|\b)(0x\h[\h_]*)\b - name - constant.numeric.integer.hexadecimal.swift - - - - integer-type - - comment - Int types - match - \bU?Int(8|16|32|64)?\b - name - support.type.swift - - keyword - - patterns - - - include - #branch-statement-keyword - - - include - #control-transfer-statement-keyword - - - include - #loop-statement-keyword - - - include - #catch-statement-keyword - - - include - #operator-declaration-modifier - - - include - #declaration-modifier - - - include - #access-level-modifier - - - comment - declaration keyword - match - \b(class|deinit|enum|extension|func|import|init|let|protocol|static|struct|subscript|typealias|var|throws|rethrows)\b - name - keyword.declaration.swift - - - comment - statement keyword - match - \b(break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|repeat|catch|guard|defer|try|throw)\b - name - keyword.statement.swift - - - comment - expression and type keyword - match - \b(as|dynamicType|is|new|super|self|Self|Type)\b - name - keyword.other.statement.swift - - - comment - other keyword - match - \b(associativity|didSet|get|infix|inout|left|mutating|none|nonmutating|operator|override|postfix|precedence|prefix|right|set|unowned((un)?safe)?|weak|willSet)\b - name - keyword.other.swift - - - - literal - - patterns - - - include - #integer-literal - - - include - #floating-point-literal - - - include - #nil-literal - - - include - #string-literal - - - include - #special-literal - - - - logical-operator - - match - (?<![/=\-+!*%<>&|\^~.])(!|&&|\|\|)(?![/=\-+!*%<>&|\^~.]) - name - keyword.operator.logical.swift - - loop-statement-keyword - - comment - loop-statement - match - \b(while|repeat|for|in)\b - name - keyword.control.loop.swift - - nil-literal - - comment - nil-literal - match - \bnil\b - name - constant.nil.swift - - operator - - patterns - - - include - #comparative-operator - - - include - #assignment-operator - - - include - #logical-operator - - - include - #remainder-operator - - - include - #increment-decrement-operator - - - include - #overflow-operator - - - include - #range-operator - - - include - #bitwise-operator - - - include - #arithmetic-operator - - - include - #ternary-operator - - - include - #type-casting-operator - - - include - #custom-operator - - - - operator-declaration-modifier - - comment - operator-declaration - match - \b(operator|prefix|infix|postfix)\b - name - keyword.other.operator.swift - - optional-type - - beginCaptures - - 1 - - name - support.type.optional.swift - - 2 - - name - punctuation.optional.begin.swift - - - end - (>) - endCaptures - - 1 - - name - punctuation.optional.end.swift - - - match - \b(Optional)(<) - name - meta.optional.swift - patterns - - - include - $self - - - - overflow-operator - - match - (?<![/=\-+!*%<>&|\^~.])\&(\+|\-|\*|\/|%)(?![/=\-+!*%<>&|\^~.]) - name - keyword.operator.overflow.swift - - parameter-clause - - begin - (\() - beginCaptures - - 1 - - name - punctuation.definition.function-arguments.begin.swift - - - comment - parameter-clause - end - (\)) - endCaptures - - 1 - - name - punctuation.definition.function-arguments.end.swift - - - name - meta.parameter-clause.swift - patterns - - - include - $self - - - - primitive-type - - comment - Primitive types - match - \b(Int|Float|Double|String|Bool|Character|Void)\b - name - support.type.swift - - protocol-composition-type - - beginCaptures - - 1 - - name - support.type.protocol.swift - - 2 - - name - punctuation.protocol.begin.swift - - - end - (>) - endCaptures - - 1 - - name - punctuation.protocol.end.swift - - - match - \b(protocol)(<) - name - meta.protocol.swift - patterns - - - include - $self - - - - range-operator - - match - (?<![/=\-+!*%<>&|\^~.])\.\.(?:\.)?(?![/=\-+!*%<>&|\^~.]) - name - keyword.operator.range.swift - - remainder-operator - - match - (?<![/=\-+!*%<>&|\^~.])\%(?![/=\-+!*%<>&|\^~.]) - name - keyword.operator.remainder.swift - - shebang-line - - captures - - 1 - - name - punctuation.definition.comment.line.shebang.swift - - - comment - Shebang line - match - ^(#!).*$ - name - comment.line.shebang.swift - - special-literal - - match - \b__(FILE|LINE|COLUMN|FUNCTION)__\b - name - keyword.other.literal.swift - - storage-type - - match - \b(var|func|let|class|enum|struct|protocol|extension|typealias)\b - name - storage.type.swift - - string-literal - - begin - \" - beginCaptures - - 0 - - name - string.quoted.double.swift - - - end - \" - endCaptures - - 0 - - name - string.quoted.double.swift - - - name - meta.literal.string.swift - patterns - - - match - \\([0tnr\"\'\\]|x\h{2}|u\h{4}|U\h{8}) - name - constant.character.escape.swift - - - begin - (\\\() - beginCaptures - - 1 - - name - support.punctuation.expression.begin.swift - - - contentName - meta.expression.swift - end - (\)) - endCaptures - - 1 - - name - support.punctuation.expression.end.swift - - - patterns - - - include - source.swift - - - - - match - (\"|\\) - name - invalid.illegal.swift - - - match - (.) - name - string.quoted.double.swift - - - - switch-statement-keyword - - comment - switch-statement - match - \b(switch|case|default|where)\b - name - keyword.control.switch.swift - - ternary-operator - - match - (?<=[\s(\[{,;:])(\?|:)(?=[\s)\]},;:]) - name - keyword.operator.ternary.swift - - type - - comment - type - patterns - - - include - #primitive-type - - - include - #integer-type - - - include - #collection-type - - - include - #optional-type - - - include - #protocol-composition-type - - - - type-casting-operator - - match - \b(is\b|as(\?\B|\b)) - name - keyword.operator.type-casting.swift - - - scopeName - source.swift - uuid - 7efa1168-97c3-4433-8dd7-15b99bf3bb53 - -