Skip to content

Commit

Permalink
[vscode] Add support for Ruby documents
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Jun 4, 2019
1 parent ab4ae80 commit 5f82fac
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- `apollo-tools`
- <First `apollo-tools` related entry goes here>
- `vscode-apollo`
- <First `vscode-apollo` related entry goes here>
- Add support for Ruby source files using `<<-GRAPHQL...GRAPHQL` heredoc. [#1304](https://github.com/apollographql/apollo-tooling/pull/1304)

## `apollo@2.12.4`, `apollo-language-server@1.9.0`, `vscode-apollo@1.7.0`

Expand Down
10 changes: 10 additions & 0 deletions packages/vscode-apollo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@
"embeddedLanguages": {
"meta.embedded.block.graphql": "graphql"
}
},
{
"injectTo": [
"source.ruby"
],
"scopeName": "inline.graphql.ruby",
"path": "./syntaxes/graphql.rb.json",
"embeddedLanguages": {
"meta.embedded.block.graphql": "graphql"
}
}
],
"commands": [
Expand Down
7 changes: 5 additions & 2 deletions packages/vscode-apollo/src/languageServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ export function getLanguageServerClient(
"javascriptreact",
"typescriptreact",
"vue",
"python"
"python",
"ruby"
],
synchronize: {
fileEvents: [
workspace.createFileSystemWatcher("**/.env"),
workspace.createFileSystemWatcher("**/*.{graphql,js,ts,jsx,tsx,vue,py}")
workspace.createFileSystemWatcher(
"**/*.{graphql,js,ts,jsx,tsx,vue,py,rb}"
)
]
},
outputChannel
Expand Down
23 changes: 23 additions & 0 deletions packages/vscode-apollo/syntaxes/graphql.rb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"fileTypes": ["rb"],
"injectionSelector": "L:source -string -comment",
"patterns": [
{
"contentName": "meta.embedded.block.graphql",
"begin": "(?=(?><<[-~](['\"]?)((?:[_\\w]+_|)GRAPHQL)\\b\\1))",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.ruby"
}
},
"end": "\\s*\\2$\\n?",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.ruby"
}
},
"patterns": [{ "include": "source.graphql" }]
}
],
"scopeName": "inline.graphql.ruby"
}

0 comments on commit 5f82fac

Please sign in to comment.