-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move vscode grammars, basic language support to standalone syntax ext…
…ension (#2573) * move vscode grammars, basic language support and snippets to graphql syntax extension. `vscode-graphql` now depends on this extension, and provides language server support in addition. this allows alternative LSP servers and non-LSP graphql extensions to use our highlighting only, or allows users to just install the syntax highlighting extension if they don't need LSP server features. * Add license Ope! * move snippets back * more work on the readme, bump version
- Loading branch information
Showing
21 changed files
with
382 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'vscode-graphql': minor | ||
'vscode-graphql-syntax': patch | ||
--- | ||
|
||
move vscode grammars, basic language support and snippets to graphql syntax extension. `vscode-graphql` now depends on this extension, and provides language server support in addition. this allows alternative LSP servers and non-LSP graphql extensions to use our highlighting only, or allows users to just install the syntax highlighting extension if they don't need LSP server features. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ cshaver | |
dhanani | ||
divy | ||
divyenduz | ||
Divyendu | ||
dotan | ||
dotansimha | ||
gillam | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 GraphQL Contributors | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 GraphQL Contributors | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 GraphQL Contributors | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
# GraphQL Syntax Support | ||
|
||
Adds full GraphQL syntax highlighting and language support such as bracket matching. | ||
|
||
- Supports `.graphql`/`.gql`/`.graphqls` highlighting | ||
- [Javascript, Typescript & JSX/TSX](#ts) & Vue | ||
- ReasonML/ReScript (`%graphql()` ) | ||
- Python | ||
- PHP | ||
- [Markdown](#markdown) | ||
|
||
You'll want to install this if you do not use `graphql-config`, or want to use the highlighting with other extensions than `vscode-graphql` | ||
|
||
## Embedded Language Usage | ||
|
||
<span id="ts"> | ||
### Javascript & Typescript | ||
|
||
The following delimiters are accepted for syntax highlighting. If you are using any of these patterns and they do not work, please open an issue! | ||
|
||
#### Template Literal Expressions | ||
|
||
```ts | ||
const query = gql` | ||
{ | ||
id | ||
} | ||
`; | ||
``` | ||
|
||
you can use these template tag literal expressions anywhere you like of course | ||
|
||
```ts | ||
useFancyGraphQLClient( | ||
graphql` | ||
{ | ||
id | ||
} | ||
`, { | ||
networkStrategy: 🚀 | ||
} | ||
) | ||
``` | ||
|
||
```ts | ||
const query = gql.experimental`{ id }`; | ||
``` | ||
|
||
and in typescript, template tag expressions with type arguments | ||
|
||
```ts | ||
const query = gql<MyType>` | ||
{ | ||
id | ||
} | ||
`; | ||
``` | ||
|
||
#### Function Expressions | ||
|
||
as well as normal function expressions with template literals | ||
|
||
```ts | ||
gql(`{ id }`); | ||
``` | ||
|
||
```ts | ||
graphql( | ||
` | ||
{ | ||
id | ||
} | ||
`, | ||
); | ||
``` | ||
|
||
there is a bug with function expressions with type arguments like these that we need to fix: | ||
|
||
```ts | ||
gql<MyType>(`{ id }`); | ||
``` | ||
|
||
Note, inline `""` and `''` string literals could also be delimited if needed, but we currently only delimit graphql template strings for obvious reasons | ||
|
||
#### Comment-Delimited patterns | ||
|
||
```ts | ||
/* GraphiQL */ | ||
const query = ` | ||
{ id } | ||
`; | ||
``` | ||
|
||
```ts | ||
const query = `#graphql | ||
{ id } | ||
`; | ||
``` | ||
|
||
For full autocompletion, validation and other features, you can install `GraphQL.vscode-graphql`, which depends on this extension | ||
|
||
<span id="markdown"> | ||
|
||
### Markdown | ||
|
||
#### backtick code blocks | ||
|
||
````markdown | ||
# Hello Jan | ||
|
||
```graphql | ||
query MyQuery {} | ||
``` | ||
```` | ||
|
||
#### embedded graphql in js & ts codeblocks | ||
|
||
simple js/ts`gql` & `graphql` template tag expression support inside any backtick codeblocks. | ||
|
||
````markdown | ||
# Hello Jan | ||
|
||
```js | ||
string : X = gql` | ||
{ | ||
its { | ||
query | ||
time | ||
} | ||
} | ||
``` | ||
```` | ||
|
||
## Other languages | ||
|
||
We actually support other languages than this! just need to extend this readme even further! 🥵 | ||
|
||
## Publishing Notes | ||
|
||
Note: this extension has temporarily been published from [this PR](https://github.com/graphql/graphiql/pull/2573) until we are ready to re-release `vscode-graphql` with it as well. | ||
|
||
## Contributing | ||
|
||
Feel free to open a PR to fix, enhance any language support, or even add new languages 😍 | ||
|
||
see: | ||
|
||
- [the grammars](grammars/) | ||
- [the applicable vscode docs](https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide) | ||
|
||
## Usage Note | ||
|
||
We would love for the other graphql extension authors to freely use this syntax extension as well! Even if your extension is designed to replace `vscode-graphql`, or if it's designed for other other purposes. It uses an MIT license, but attribution is always a nice gesture to the original authors :) | ||
|
||
## License | ||
|
||
MIT License | ||
|
||
Copyright 2022 GraphQL Contributors |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
{ | ||
"name": "vscode-graphql-syntax", | ||
"version": "1.0.3", | ||
"displayName": "GraphQL: Syntax Highlighting", | ||
"description": "Adds syntax highlighting support for .graphql & embedded support for javascript, typescript, vue, markdown, python, php, reason, ocaml and rescript", | ||
"publisher": "GraphQL", | ||
"license": "MIT", | ||
"engines": { | ||
"vscode": "^1.63.0" | ||
}, | ||
"icon": "assets/images/logo.png", | ||
"contributors": [ | ||
{ | ||
"name": "Divyendu Singh", | ||
"url": "https://www.divyendusingh.com/" | ||
} | ||
], | ||
"galleryBanner": { | ||
"color": "#032539", | ||
"theme": "dark" | ||
}, | ||
"categories": [ | ||
"Programming Languages" | ||
], | ||
"contributes": { | ||
"languages": [ | ||
{ | ||
"id": "graphql", | ||
"extensions": [ | ||
".gql", | ||
".graphql", | ||
".graphqls" | ||
], | ||
"aliases": [ | ||
"GraphQL", | ||
"graphql" | ||
], | ||
"configuration": "./language/language-configuration.json" | ||
} | ||
], | ||
"grammars": [ | ||
{ | ||
"language": "graphql", | ||
"path": "./grammars/graphql.json", | ||
"scopeName": "source.graphql" | ||
}, | ||
{ | ||
"injectTo": [ | ||
"source.js", | ||
"source.ts", | ||
"source.js.jsx", | ||
"source.tsx", | ||
"source.vue", | ||
"source.svelte" | ||
], | ||
"scopeName": "inline.graphql", | ||
"path": "./grammars/graphql.js.json", | ||
"embeddedLanguages": { | ||
"meta.embedded.block.graphql": "graphql" | ||
} | ||
}, | ||
{ | ||
"injectTo": [ | ||
"source.reason", | ||
"source.ocaml" | ||
], | ||
"scopeName": "inline.graphql.re", | ||
"path": "./grammars/graphql.re.json", | ||
"embeddedLanguages": { | ||
"meta.embedded.block.graphql": "graphql" | ||
} | ||
}, | ||
{ | ||
"injectTo": [ | ||
"source.rescript" | ||
], | ||
"scopeName": "inline.graphql.res", | ||
"path": "./grammars/graphql.rescript.json", | ||
"embeddedLanguages": { | ||
"meta.embedded.block.graphql": "graphql" | ||
} | ||
}, | ||
{ | ||
"injectTo": [ | ||
"text.html.markdown" | ||
], | ||
"scopeName": "markdown.graphql.codeblock", | ||
"path": "./grammars/graphql.markdown.codeblock.json", | ||
"embeddedLanguages": { | ||
"meta.embedded.block.graphql": "graphql" | ||
} | ||
}, | ||
{ | ||
"injectTo": [ | ||
"source.python" | ||
], | ||
"scopeName": "inline.graphql.python", | ||
"path": "./grammars/graphql.python.json", | ||
"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" | ||
} | ||
} | ||
] | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/graphql/graphiql", | ||
"directory": "packages/vscode-graphql-syntax" | ||
}, | ||
"homepage": "https://github.com/graphql/graphiql/blob/main/packages/vscode-graphql-syntax/README.md", | ||
"scripts": { | ||
"vsce:package": "vsce package --yarn", | ||
"vsce:prepublish": "npm run vsce:package", | ||
"vsce:publish": "vsce publish --yarn", | ||
"open-vsx:publish": "ovsx publish", | ||
"release": "npm run vsce:publish && npm run open-vsx:publish" | ||
} | ||
} |
Oops, something went wrong.