Skip to content

Commit

Permalink
feat: Add support for graphql in python snippets (#2556)
Browse files Browse the repository at this point in the history
  • Loading branch information
qw-in authored Jul 12, 2022
1 parent 3dd0cd8 commit e04dd9c
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-buses-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vscode-graphql': minor
---

Add support for syntax highlighting in python files
147 changes: 147 additions & 0 deletions packages/vscode-graphql/grammars/graphql.python.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
{
"fileTypes": ["python"],
"injectionSelector": "L:source.python -string -comment",
"patterns": [
{
"contentName": "meta.embedded.block.graphql",
"begin": "\\s+(gql)\\s*\\(\\s*(''')",
"beginCaptures": {
"1": {
"name": "entity.name.function"
},
"2": {
"name": "string.quoted.multi.python"
}
},
"end": "(''')",
"endCaptures": {
"1": {
"name": "string.quoted.multi.python"
}
},
"patterns": [
{
"include": "source.graphql"
}
]
},
{
"contentName": "meta.embedded.block.graphql",
"begin": "\\s+(gql)\\s*\\(\\s*(\"\"\")",
"beginCaptures": {
"1": {
"name": "entity.name.function"
},
"2": {
"name": "string.quoted.multi.python"
}
},
"end": "(\"\"\")",
"endCaptures": {
"1": {
"name": "string.quoted.multi.python"
}
},
"patterns": [
{
"include": "source.graphql"
}
]
},
{
"contentName": "meta.embedded.block.graphql",
"begin": "\\s+(gql)\\s*\\(\\s*$",
"beginCaptures": {
"1": {
"name": "entity.name.function"
}
},
"end": "\\)|,",
"patterns": [
{
"begin": "^\\s*(''')",
"beginCaptures": {
"1": {
"name": "string.quoted.multi.python"
}
},
"end": "(''')",
"endCaptures": {
"1": {
"name": "string.quoted.multi.python"
}
},
"patterns": [
{
"include": "source.graphql"
}
]
},
{
"begin": "^\\s*(\"\"\")",
"beginCaptures": {
"1": {
"name": "string.quoted.multi.python"
}
},
"end": "(\"\"\")",
"endCaptures": {
"1": {
"name": "string.quoted.multi.python"
}
},
"patterns": [
{
"include": "source.graphql"
}
]
}
]
},
{
"begin": "(''')(#graphql)",
"beginCaptures": {
"1": {
"name": "string.quoted.multi.python"
},
"2": {
"name": "comment.line.graphql.js"
}
},
"end": "(''')",
"endCaptures": {
"1": {
"name": "string.quoted.multi.python"
}
},
"patterns": [
{
"include": "source.graphql"
}
]
},
{
"begin": "(\"\"\")(#graphql)",
"beginCaptures": {
"1": {
"name": "string.quoted.multi.python"
},
"2": {
"name": "comment.line.graphql.js"
}
},
"end": "(\"\"\")",
"endCaptures": {
"1": {
"name": "string.quoted.multi.python"
}
},
"patterns": [
{
"include": "source.graphql"
}
]
}
],
"scopeName": "inline.graphql.python"
}
10 changes: 10 additions & 0 deletions packages/vscode-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@
"embeddedLanguages": {
"meta.embedded.block.graphql": "graphql"
}
},
{
"injectTo": [
"source.python"
],
"scopeName": "inline.graphql.python",
"path": "./grammars/graphql.python.json",
"embeddedLanguages": {
"meta.embedded.block.graphql": "graphql"
}
}
],
"snippets": [
Expand Down

0 comments on commit e04dd9c

Please sign in to comment.