Skip to content

Commit 51bff20

Browse files
author
Kumar Harsh
committed
feat(syntax): add syntax highlighting for feature files
1 parent d9c8086 commit 51bff20

File tree

4 files changed

+68
-3
lines changed

4 files changed

+68
-3
lines changed

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"contributors": [
2323
{
2424
"name": "Mayank Agarwal (@Mayank1791989)",
25-
"url": "github.com/Mayank1791989",
25+
"url": "https://github.com/Mayank1791989",
2626
"email": "[email protected]"
2727
}
2828
],
@@ -115,6 +115,13 @@
115115
"embeddedLanguages": {
116116
"meta.embedded.block.graphql": "graphql"
117117
}
118+
},
119+
{
120+
"injectTo": [
121+
"text.gherkin.feature"
122+
],
123+
"scopeName": "text.gherkin.feature.graphql",
124+
"path": "./syntaxes/graphql.feature.json"
118125
}
119126
],
120127
"snippets": [

syntaxes/graphql.feature.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"fileTypes": ["feature"],
3+
"scopeName": "text.gherkin.feature.graphql",
4+
"injectionSelector": "L:text -comment",
5+
"patterns": [
6+
{
7+
"begin": "graphql request\\s*$",
8+
"patterns": [
9+
{
10+
"begin": "^\\s*(\"\"\")$",
11+
"beginCaptures": {
12+
"1": { "name": "string.quoted.double.graphql.begin" }
13+
},
14+
"end": "^\\s*(\"\"\")$",
15+
"endCaptures": {
16+
"1": { "name": "string.quoted.double.graphql.end" }
17+
},
18+
"patterns": [
19+
{ "include": "source.graphql" }
20+
]
21+
}
22+
]
23+
},
24+
{
25+
"begin": "^\\s*(\"\"\")\\s*(#graphql)\\s*$",
26+
"beginCaptures": {
27+
"1": { "name": "string.quoted.double.graphql.begin" },
28+
"2": { "name": "comment.line.graphql.js" }
29+
},
30+
"end": "^\\s*(\"\"\")$",
31+
"endCaptures": {
32+
"1": { "name": "string.quoted.double.graphql.end" }
33+
},
34+
"patterns": [
35+
{ "include": "source.graphql" }
36+
]
37+
}
38+
]
39+
}

syntaxes/graphql.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@
7373
"begin": "\\s*\\b(implements)\\b\\s*",
7474
"end": "\\s*(?={)",
7575
"beginCaptures": {
76-
"1": { "name": "keyword.implements.graphql.RRR" }
76+
"1": { "name": "keyword.implements.graphql" }
7777
},
7878
"patterns": [
7979
{
8080
"match": "\\s*([_A-Za-z][_0-9A-Za-z]*)",
8181
"captures": {
82-
"1": { "name": "support.type.graphql.XXX" }
82+
"1": { "name": "support.type.graphql" }
8383
}
8484
},
8585
{ "include": "#graphql-comma" }

test/test.feature

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Scenario: Logs a user into the system using username
2+
When I make a graphql request
3+
"""
4+
mutation {
5+
UserLogin(input: {username: "foo"}) {
6+
clientMutationId
7+
}
8+
}
9+
"""
10+
11+
Scenario: Logs a user into the system using username
12+
When I send this mutation
13+
""" #graphql
14+
mutation {
15+
UserLogin(input: {username: "foo"}) {
16+
clientMutationId
17+
}
18+
}
19+
"""

0 commit comments

Comments
 (0)