Skip to content

Commit 7cfd8db

Browse files
committed
1.0.0: GraphQL syntax
0 parents  commit 7cfd8db

2 files changed

Lines changed: 149 additions & 0 deletions

File tree

GraphQL.sublime-syntax

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
%YAML 1.2
2+
---
3+
# See http://www.sublimetext.com/docs/3/syntax.html
4+
name: GraphQL Language
5+
file_extensions:
6+
- graphql
7+
- gql
8+
scope: source.graphql
9+
contexts:
10+
main:
11+
# Strings begin and end with quotes, and use backslashes as an escape
12+
# character
13+
- match: '"'
14+
scope: punctuation.definition.string.begin.graphql
15+
push: double_quoted_string
16+
17+
# Comments begin with a '//' and finish at the end of the line
18+
- match: '#'
19+
scope: punctuation.definition.comment.graphql
20+
push: line_comment
21+
22+
# Brace matching
23+
- match: '{'
24+
push: brackets
25+
26+
- match: '\('
27+
push: parentheses
28+
29+
# End of Braces
30+
- match: '}'
31+
scope: invalid.illegal.stray-bracket-end
32+
33+
# Argument Property
34+
- match: '(?<=\()\w+(?=\:)'
35+
scope: string.property.argument.graphql
36+
37+
# Property names
38+
- match: '\b\w+(?=\:)'
39+
scope: string.property.graphql
40+
41+
# Has Arguments
42+
- match: '\b\w+(?=\()'
43+
scope: string.property.graphql
44+
45+
# Symbols
46+
- match: '\:'
47+
scope: constant.other.object.key.graphql
48+
49+
- match: '!'
50+
scope: keyword.control.non-null.graphql
51+
52+
- match: '\|'
53+
scope: keyword.control.union.graphql
54+
55+
- match: '='
56+
scope: keyword.operator.assignment.graphql
57+
58+
# Storage Types
59+
- match: '\btype\b'
60+
scope: storage.type.type.graphql
61+
62+
- match: '\bschema\b'
63+
scope: storage.type.schema.graphql
64+
65+
- match: '\binterface\b'
66+
scope: storage.type.interface.graphql
67+
68+
- match: '\bimplements\b'
69+
scope: storage.type.implements.graphql
70+
71+
- match: '\binput\b'
72+
scope: storage.type.input.graphql
73+
74+
- match: '\bscalar\b'
75+
scope: storage.type.scalar.graphql
76+
77+
- match: '\bunion\b'
78+
scope: storage.type.union.graphql
79+
80+
- match: '\benum\b'
81+
scope: storage.type.enum.graphql
82+
83+
# Storage type names
84+
- match: '(?<=type )\w+\b'
85+
scope: meta.type.type
86+
87+
- match: '(?<=schema )\w+\b'
88+
scope: meta.type.schema
89+
90+
- match: '(?<=interface )\w+\b'
91+
scope: meta.type.interface
92+
93+
- match: '(?<=implements )\w+\b'
94+
scope: meta.type.implements meta.type.interface
95+
96+
- match: '(?<=input )\w+\b'
97+
scope: meta.type.input
98+
99+
- match: '(?<=scalar )\w+\b'
100+
scope: meta.type.scalar
101+
102+
- match: '(?<=union )\w+\b'
103+
scope: meta.type.union
104+
105+
- match: '(?<=enum )\w+\b'
106+
scope: meta.type.enum
107+
108+
# Numbers
109+
- match: '\b(-)?[0-9.]+\b'
110+
scope: constant.numeric.graphql
111+
112+
brackets:
113+
- match: '}'
114+
pop: true
115+
- include: main
116+
117+
parentheses:
118+
- match: '\b\w+(?=\:)'
119+
scope: variable.parameter.arguments.graphql
120+
- match: '\)'
121+
pop: true
122+
- include: main
123+
124+
double_quoted_string:
125+
- meta_scope: string.quoted.double.graphql
126+
- match: '\\.'
127+
scope: constant.character.escape.graphql
128+
- match: '"'
129+
scope: punctuation.definition.string.end.graphql
130+
pop: true
131+
132+
line_comment:
133+
- meta_scope: comment.line.graphql
134+
- match: $
135+
pop: true

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
# GraphQL Language Definition for SublimeText 3
3+
4+
GraphQL language definition for SublimeText.
5+
6+
## Installation and Use
7+
8+
1. [Install Package Control](https://sublime.wbond.net/installation)
9+
2. `Package Control: Install Package` => `GraphQL Syntax`
10+
11+
12+
## Contributing
13+
14+
This is still super young. I'd appreciate any contribution. [PLEASE HELP](https://www.youtube.com/watch?v=1eSMxRya2S8)

0 commit comments

Comments
 (0)