Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@
"filenamePatterns": [
"*.tutorial"
]
},
{
"id": "swift-gyb",
"aliases": [
"Swift GYB"
],
"extensions": [
".swift.gyb"
],
"configuration": "./swift-gyb.language-configuration.json"
}
],
"grammars": [
{
"language": "swift-gyb",
"scopeName": "source.swift.gyb",
"path": "./syntaxes/swift-gyb.tmLanguage.json",
"embeddedLanguages": {
"meta.embedded.block.gyb": "python",
"meta.embedded.control.begin.gyb": "python",
"meta.embedded.expression.gyb": "python"
}
}
],
"snippets": [
Expand Down
19 changes: 19 additions & 0 deletions swift-gyb.language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"brackets": [
["{", "}"]
],
"autoClosingPairs": [
["%{", "}%"],
["${", "}"]
],
"surroundingPairs": [
["%{", "}%"],
["${", "}"]
],
"folding": {
"markers": {
"start": "^\\s*(?:%\\{|%[^\\{].*?:)",
"end": "^\\s*(?:\\}%|%\\s*end\\b)"
}
}
}
95 changes: 95 additions & 0 deletions syntaxes/swift-gyb.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Swift GYB",
"patterns": [
{ "include": "#gyb-code-block" },
{ "include": "#gyb-start-control-statement" },
{ "include": "#gyb-end-control-statement" },
{ "include": "#gyb-expression" },
{ "include": "source.swift" }
],
"repository": {
"gyb-code-block": {
"name": "meta.embedded.block.gyb",
"begin": "(%)\\{",
"beginCaptures": {
"1": { "name": "keyword.control.gyb" },
"0": { "name": "punctuation.section.block.begin.gyb" }
},
"end": "\\}(%)",
"endCaptures": {
"1": { "name": "keyword.control.gyb" },
"0": { "name": "punctuation.section.block.end.gyb" }
},
"patterns": [
{ "include": "source.python" }
]
},
"gyb-start-control-statement": {
"name": "meta.embedded.control.begin.gyb",
"begin": "(%)(?!\\{|\\s*end\\b).+?",
"beginCaptures": {
"1": { "name": "keyword.control.flow.gyb" }
},
"end": ":",
"endCaptures": {
"0": { "name": "punctuation.separator.colon.gyb" }
},
"patterns": [
{ "include": "source.python" }
]
},
"gyb-end-control-statement": {
"name": "meta.embedded.control.end.gyb",
"match": "%\\s*end\\b",
"captures": {
"0": { "name": "keyword.control.flow.gyb" }
}
},
"gyb-expression": {
"name": "meta.embedded.expression.gyb",
"begin": "(\\$)\\{",
"beginCaptures": {
"1": { "name": "variable.other.gyb" },
"0": { "name": "punctuation.section.expression.begin.gyb" }
},
"end": "\\}",
"endCaptures": {
"0": { "name": "punctuation.section.expression.end.gyb" }
},
"patterns": [
{ "include": "source.python" }
]
}
},
"injections": {
"source.swift": {
"patterns": [
{ "include": "#gyb-code-block" },
{ "include": "#gyb-start-control-statement" },
{ "include": "#gyb-end-control-statement" },
{ "include": "#gyb-expression" }
]
},
"source.python": {
"patterns": [
{ "include": "#gyb-code-block" },
{ "include": "#gyb-start-control-statement" },
{ "include": "#gyb-end-control-statement" },
{ "include": "#gyb-expression" }
]
},
"source.swift.gyb": {
"patterns": [
{ "include": "#gyb-code-block" },
{ "include": "#gyb-start-control-statement" },
{ "include": "#gyb-end-control-statement" },
{ "include": "#gyb-expression" }
]
}
},
"scopeName": "source.swift.gyb",
"fileTypes": ["swift.gyb"],
"foldingStartMarker": "^\\s*(?:%\\{|%[^\\{].*?:)",
"foldingStopMarker": "^\\s*(?:\\}%|%\\s*end\\b)"
}
Loading