Skip to content

Commit

Permalink
feat: add php syntax highlighting for strings
Browse files Browse the repository at this point in the history
  • Loading branch information
cobbles authored and acao committed Jul 13, 2022
1 parent 362cd47 commit 55208ec
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 1 deletion.
3 changes: 2 additions & 1 deletion custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dotansimha
gillam
goldshtein
goncharov
graphi
harshith
heyenbrock
hurrell
Expand All @@ -31,6 +32,7 @@ leebyron
lostplan
nauroze
nishchit
nowdoc
orta
pabbati
pratap
Expand Down Expand Up @@ -198,4 +200,3 @@ typeahead
typeaheads
unparsable
randomthing

131 changes: 131 additions & 0 deletions packages/vscode-graphql/grammars/graphql.php.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"fileTypes": ["php"],
"injectionSelector": "L:source -string -comment",
"patterns": [
{
"contentName": "meta.embedded.block.graphql",
"begin": "(<<<)\\s*(\"?)(GRAPHQL|GQL)(\\2)(\\s*)$",
"beginCaptures": {
"0": {
"name": "punctuation.section.embedded.begin.php"
},
"1": {
"name": "punctuation.definition.string.php"
},
"3": {
"name": "keyword.operator.heredoc.php"
},
"5": {
"name": "invalid.illegal.trailing-whitespace.php"
}
},
"end": "^\\s*(\\3)(?![A-Za-z0-9_\\x{7f}-\\x{10ffff}])",
"endCaptures": {
"0": {
"name": "punctuation.section.embedded.end.php"
},
"1": {
"name": "keyword.operator.heredoc.php"
}
},
"patterns": [
{
"include": "source.graphql"
}
]
},
{
"begin": "(<<<)\\s*'(GRAPHQL|GQL)'(\\s*)$",
"beginCaptures": {
"0": {
"name": "punctuation.section.embedded.begin.php"
},
"1": {
"name": "punctuation.definition.string.php"
},
"2": {
"name": "keyword.operator.nowdoc.php"
},
"3": {
"name": "invalid.illegal.trailing-whitespace.php"
}
},
"contentName": "source.graphql",
"end": "^\\s*(\\2)(?![A-Za-z0-9_\\x{7f}-\\x{10ffff}])",
"endCaptures": {
"0": {
"name": "punctuation.section.embedded.end.php"
},
"1": {
"name": "keyword.operator.nowdoc.php"
}
},
"name": "meta.embedded.graphql",
"patterns": [
{
"include": "source.graphql"
}
]
},
{
"begin": "(/\\*\\*\\s*(@lang\\s*GraphQL|Graphi?QL|graphql)\\s*\\*/)\\s*(')",
"beginCaptures": {
"1": {
"name": "punctuation.definition.comment.php"
},
"3": {
"name": "punctuation.definition.string.begin.php"
}
},
"contentName": "source.graphql",
"end": "'",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.php"
}
},
"name": "meta.embedded.graphql",
"patterns": [
{
"include": "source.graphql"
}
]
},
{
"begin": "((/\\*\\*|//)\\s*(@lang\\s*GraphQL|Graphi?QL|graphql)\\s*(\\*/)?)(\\s*)$",
"beginCaptures": {
"1": {
"name": "punctuation.definition.comment.php"
},
"5": {
"name": "invalid.illegal.trailing-whitespace.php"
}
},
"end": "(?<=')",
"patterns": [
{
"begin": "'",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.php"
}
},
"contentName": "source.graphql",
"end": "'",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.php"
}
},
"name": "meta.embedded.graphql",
"patterns": [
{
"include": "source.graphql"
}
]
}
]
}
],
"scopeName": "inline.graphql.php"
}
10 changes: 10 additions & 0 deletions packages/vscode-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@
"embeddedLanguages": {
"meta.embedded.block.graphql": "graphql"
}
},
{
"injectTo": [
"text.html.php"
],
"scopeName": "inline.graphql.php",
"path": "./grammars/graphql.php.json",
"embeddedLanguages": {
"meta.embedded.block.graphql": "graphql"
}
}
],
"snippets": [
Expand Down

0 comments on commit 55208ec

Please sign in to comment.