"completed"
45 | | Some(false)
46 | | None => ""
47 | }}>
48 |
49 |
81 |
82 |
84 | DeleteMutation.commitMutation(
85 | ~environment=RelayEnv.environment,
86 | ~variables={
87 | input: {
88 | clientMutationId: None,
89 | id: todoItem.id,
90 | },
91 | connections: [todosConnectionId->RescriptRelay.dataIdToString],
92 | },
93 | ~optimisticResponse={
94 | deleteTodoItem: Some({deletedTodoItemId: Some(todoItem.id)}),
95 | },
96 | (),
97 | ) |> ignore}
98 | role="button"
99 | className="remove mdi mdi-close-circle-outline"
100 | />
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/src/utils.ts:
--------------------------------------------------------------------------------
1 | import { workspace } from "vscode";
2 |
3 | export function getPreferredFragmentPropName(onType: string): string {
4 | const result =
5 | workspace.getConfiguration("rescript-relay").get("preferShortNames") ===
6 | true
7 | ? onType.split(/(?=[A-Z])|_/g).pop() ?? onType
8 | : onType;
9 |
10 | // Handle common ReScript keywords
11 | if (result.toLowerCase().endsWith("type")) {
12 | return result.slice(0, result.length - 1);
13 | }
14 |
15 | return result;
16 | }
17 |
18 | export const featureEnabled = (key: string) =>
19 | workspace.getConfiguration("rescript-relay").get(key) === true;
20 |
--------------------------------------------------------------------------------
/src/utilsNoVsCode.ts:
--------------------------------------------------------------------------------
1 | import semver from "semver";
2 |
3 | export function hasHighEnoughReScriptRelayVersion(version: string): boolean {
4 | return semver.satisfies(version.replace(/[\^\~]/g, ""), ">=0.13.0");
5 | }
6 |
--------------------------------------------------------------------------------
/syntaxes/graphql.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "GraphQL",
3 | "scopeName": "source.graphql",
4 | "fileTypes": ["graphql", "graphqls", "gql", "graphcool"],
5 | "patterns": [
6 | {
7 | "include": "#graphql"
8 | }
9 | ],
10 | "repository": {
11 | "graphql": {
12 | "patterns": [
13 | {
14 | "include": "#graphql-fragment-definition"
15 | },
16 | {
17 | "include": "#graphql-type-interface"
18 | },
19 | {
20 | "include": "#graphql-enum"
21 | },
22 | {
23 | "include": "#graphql-scalar"
24 | },
25 | {
26 | "include": "#graphql-union"
27 | },
28 | {
29 | "include": "#graphql-schema"
30 | },
31 | {
32 | "include": "#graphql-operation-def"
33 | },
34 | {
35 | "include": "#graphql-comment"
36 | },
37 | {
38 | "include": "#literal-quasi-embedded"
39 | }
40 | ]
41 | },
42 | "graphql-operation-def": {
43 | "patterns": [
44 | {
45 | "include": "#graphql-query-mutation-subscription"
46 | },
47 | {
48 | "include": "#graphql-directive-definition"
49 | },
50 | {
51 | "include": "#graphql-name"
52 | },
53 | {
54 | "include": "#graphql-variable-definitions"
55 | },
56 | {
57 | "include": "#graphql-directive"
58 | },
59 | {
60 | "include": "#graphql-selection-set"
61 | }
62 | ]
63 | },
64 | "graphql-fragment-definition": {
65 | "name": "meta.fragment.graphql",
66 | "begin": "\\s*(?:(\\bfragment\\b)\\s*([_A-Za-z][_0-9A-Za-z]*)?\\s*(?:(\\bon\\b)\\s*([_A-Za-z][_0-9A-Za-z]*)))",
67 | "end": "(?<=})",
68 | "captures": {
69 | "1": {
70 | "name": "keyword.fragment.graphql"
71 | },
72 | "2": {
73 | "name": "entity.name.fragment.graphql"
74 | },
75 | "3": {
76 | "name": "keyword.on.graphql"
77 | },
78 | "4": {
79 | "name": "support.type.graphql"
80 | }
81 | },
82 | "patterns": [
83 | {
84 | "include": "#graphql-comment"
85 | },
86 | {
87 | "include": "#graphql-selection-set"
88 | },
89 | {
90 | "include": "#graphql-directive"
91 | },
92 | {
93 | "include": "#graphql-skip-newlines"
94 | },
95 | {
96 | "include": "#literal-quasi-embedded"
97 | }
98 | ]
99 | },
100 | "graphql-query-mutation-subscription": {
101 | "match": "\\s*\\b(query|mutation|subscription)\\b",
102 | "captures": {
103 | "1": {
104 | "name": "keyword.operation.graphql"
105 | }
106 | }
107 | },
108 | "graphql-type-interface": {
109 | "name": "meta.type.interface.graphql",
110 | "begin": "\\s*\\b(?:(extend)?\\b\\s*\\b(type)|(interface)|(input))\\b\\s*([_A-Za-z][_0-9A-Za-z]*)?",
111 | "end": "(?<=})",
112 | "captures": {
113 | "1": {
114 | "name": "keyword.extend.graphql"
115 | },
116 | "2": {
117 | "name": "keyword.type.graphql"
118 | },
119 | "3": {
120 | "name": "keyword.interface.graphql"
121 | },
122 | "4": {
123 | "name": "keyword.input.graphql"
124 | },
125 | "5": {
126 | "name": "support.type.graphql"
127 | }
128 | },
129 | "patterns": [
130 | {
131 | "begin": "\\s*\\b(implements)\\b\\s*",
132 | "end": "\\s*(?={)",
133 | "beginCaptures": {
134 | "1": {
135 | "name": "keyword.implements.graphql.RRR"
136 | }
137 | },
138 | "patterns": [
139 | {
140 | "match": "\\s*([_A-Za-z][_0-9A-Za-z]*)",
141 | "captures": {
142 | "1": {
143 | "name": "support.type.graphql.XXX"
144 | }
145 | }
146 | },
147 | {
148 | "include": "#graphql-comma"
149 | }
150 | ]
151 | },
152 | {
153 | "include": "#graphql-directive"
154 | },
155 | {
156 | "include": "#graphql-comment"
157 | },
158 | {
159 | "include": "#graphql-type-object"
160 | },
161 | {
162 | "include": "#literal-quasi-embedded"
163 | }
164 | ]
165 | },
166 | "graphql-type-object": {
167 | "name": "meta.type.object.graphql",
168 | "begin": "\\s*({)",
169 | "end": "\\s*(})",
170 | "beginCaptures": {
171 | "1": {
172 | "name": "punctuation.operation.graphql"
173 | }
174 | },
175 | "endCaptures": {
176 | "1": {
177 | "name": "punctuation.operation.graphql"
178 | }
179 | },
180 | "patterns": [
181 | {
182 | "include": "#graphql-object-type"
183 | },
184 | {
185 | "include": "#graphql-comment"
186 | },
187 | {
188 | "include": "#graphql-type-definition"
189 | },
190 | {
191 | "include": "#literal-quasi-embedded"
192 | }
193 | ]
194 | },
195 | "graphql-type-definition": {
196 | "comment": "key (optionalArgs): Type",
197 | "begin": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?=\\s*\\(|:)",
198 | "end": "(?=\\s*(([_A-Za-z][_0-9A-Za-z]*)\\s*(\\(|:)|(})))|\\s*(,)",
199 | "beginCaptures": {
200 | "1": {
201 | "name": "variable.graphql"
202 | }
203 | },
204 | "endCaptures": {
205 | "5": {
206 | "name": "punctuation.comma.graphql"
207 | }
208 | },
209 | "patterns": [
210 | {
211 | "include": "#graphql-comment"
212 | },
213 | {
214 | "include": "#graphql-variable-definitions"
215 | },
216 | {
217 | "include": "#graphql-type-object"
218 | },
219 | {
220 | "include": "#graphql-colon"
221 | },
222 | {
223 | "include": "#graphql-input-types"
224 | },
225 | {
226 | "include": "#graphql-directive"
227 | },
228 | {
229 | "include": "#literal-quasi-embedded"
230 | }
231 | ]
232 | },
233 | "graphql-schema": {
234 | "begin": "\\s*\\b(schema)\\b",
235 | "end": "(?<=})",
236 | "beginCaptures": {
237 | "1": {
238 | "name": "keyword.schema.graphql"
239 | }
240 | },
241 | "patterns": [
242 | {
243 | "begin": "\\s*({)",
244 | "end": "\\s*(})",
245 | "beginCaptures": {
246 | "1": {
247 | "name": "punctuation.operation.graphql"
248 | }
249 | },
250 | "endCaptures": {
251 | "1": {
252 | "name": "punctuation.operation.graphql"
253 | }
254 | },
255 | "patterns": [
256 | {
257 | "begin": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?=\\s*\\(|:)",
258 | "end": "(?=\\s*(([_A-Za-z][_0-9A-Za-z]*)\\s*(\\(|:)|(})))|\\s*(,)",
259 | "beginCaptures": {
260 | "1": {
261 | "name": "variable.arguments.graphql"
262 | }
263 | },
264 | "endCaptures": {
265 | "5": {
266 | "name": "punctuation.comma.graphql"
267 | }
268 | },
269 | "patterns": [
270 | {
271 | "match": "\\s*([_A-Za-z][_0-9A-Za-z]*)",
272 | "captures": {
273 | "1": {
274 | "name": "support.type.graphql"
275 | }
276 | }
277 | },
278 | {
279 | "include": "#graphql-colon"
280 | },
281 | {
282 | "include": "#graphql-comment"
283 | },
284 | {
285 | "include": "#graphql-skip-newlines"
286 | }
287 | ]
288 | },
289 | {
290 | "include": "#graphql-comment"
291 | },
292 | {
293 | "include": "#graphql-skip-newlines"
294 | }
295 | ]
296 | },
297 | {
298 | "include": "#graphql-comment"
299 | },
300 | {
301 | "include": "#graphql-skip-newlines"
302 | }
303 | ]
304 | },
305 | "graphql-directive-definition": {
306 | "begin": "\\s*(\\bdirective\\b)\\s*(@[_A-Za-z][_0-9A-Za-z]*)",
307 | "end": "(?=.)",
308 | "applyEndPatternLast": 1,
309 | "beginCaptures": {
310 | "1": {
311 | "name": "keyword.directive.graphql"
312 | },
313 | "2": {
314 | "name": "entity.name.function.directive.graphql"
315 | }
316 | },
317 | "patterns": [
318 | {
319 | "include": "#graphql-variable-definitions"
320 | },
321 | {
322 | "begin": "\\s*(\\bon\\b)\\s*([_A-Za-z]*)",
323 | "end": "(?=.)",
324 | "applyEndPatternLast": 1,
325 | "beginCaptures": {
326 | "1": {
327 | "name": "keyword.on.graphql"
328 | },
329 | "2": {
330 | "name": "support.type.location.graphql"
331 | }
332 | },
333 | "patterns": [
334 | {
335 | "include": "#graphql-skip-newlines"
336 | },
337 | {
338 | "include": "#graphql-comment"
339 | },
340 | {
341 | "include": "#literal-quasi-embedded"
342 | },
343 | {
344 | "match": "\\s*(\\|)\\s*([_A-Za-z]*)",
345 | "captures": {
346 | "2": {
347 | "name": "support.type.location.graphql"
348 | }
349 | }
350 | }
351 | ]
352 | },
353 | {
354 | "include": "#graphql-skip-newlines"
355 | },
356 | {
357 | "include": "#graphql-comment"
358 | },
359 | {
360 | "include": "#literal-quasi-embedded"
361 | }
362 | ]
363 | },
364 | "graphql-comment": {
365 | "patterns": [
366 | {
367 | "comment": "need to prefix comment space with a scope else Atom's reflow cmd doesn't work",
368 | "name": "comment.line.graphql.js",
369 | "match": "(\\s*)(#).*",
370 | "captures": {
371 | "1": {
372 | "name": "punctuation.whitespace.comment.leading.graphql"
373 | }
374 | }
375 | },
376 | {
377 | "name": "comment.line.graphql.js",
378 | "begin": "(\"\"\")",
379 | "end": "(\"\"\")",
380 | "beginCaptures": {
381 | "1": {
382 | "name": "punctuation.whitespace.comment.leading.graphql"
383 | }
384 | }
385 | },
386 | {
387 | "name": "comment.line.graphql.js",
388 | "begin": "(\")",
389 | "end": "(\")",
390 | "beginCaptures": {
391 | "1": {
392 | "name": "punctuation.whitespace.comment.leading.graphql"
393 | }
394 | }
395 | }
396 | ]
397 | },
398 | "graphql-variable-definitions": {
399 | "begin": "\\s*(\\()",
400 | "end": "\\s*(\\))",
401 | "captures": {
402 | "1": {
403 | "name": "meta.brace.round.graphql"
404 | }
405 | },
406 | "patterns": [
407 | {
408 | "include": "#graphql-comment"
409 | },
410 | {
411 | "include": "#graphql-variable-definition"
412 | },
413 | {
414 | "include": "#literal-quasi-embedded"
415 | }
416 | ]
417 | },
418 | "graphql-variable-definition": {
419 | "comment": "variable: type = value,.... which may be a list",
420 | "name": "meta.variables.graphql",
421 | "begin": "\\s*(\\$?[_A-Za-z][_0-9A-Za-z]*)(?=\\s*\\(|:)",
422 | "end": "(?=\\s*((\\$?[_A-Za-z][_0-9A-Za-z]*)\\s*(\\(|:)|(}|\\))))|\\s*(,)",
423 | "beginCaptures": {
424 | "1": {
425 | "name": "variable.parameter.graphql"
426 | }
427 | },
428 | "endCaptures": {
429 | "5": {
430 | "name": "punctuation.comma.graphql"
431 | }
432 | },
433 | "patterns": [
434 | {
435 | "include": "#graphql-comment"
436 | },
437 | {
438 | "include": "#graphql-colon"
439 | },
440 | {
441 | "include": "#graphql-input-types"
442 | },
443 | {
444 | "include": "#graphql-variable-assignment"
445 | },
446 | {
447 | "include": "#literal-quasi-embedded"
448 | },
449 | {
450 | "include": "#graphql-skip-newlines"
451 | }
452 | ]
453 | },
454 | "graphql-input-types": {
455 | "patterns": [
456 | {
457 | "include": "#graphql-scalar-type"
458 | },
459 | {
460 | "match": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?:\\s*(!))?",
461 | "captures": {
462 | "1": {
463 | "name": "support.type.graphql"
464 | },
465 | "2": {
466 | "name": "keyword.operator.nulltype.graphql"
467 | }
468 | }
469 | },
470 | {
471 | "name": "meta.type.list.graphql",
472 | "begin": "\\s*(\\[)",
473 | "end": "\\s*(\\])(?:\\s*(!))?",
474 | "captures": {
475 | "1": {
476 | "name": "meta.brace.square.graphql"
477 | },
478 | "2": {
479 | "name": "keyword.operator.nulltype.graphql"
480 | }
481 | },
482 | "patterns": [
483 | {
484 | "include": "#graphql-input-types"
485 | },
486 | {
487 | "include": "#graphql-comment"
488 | },
489 | {
490 | "include": "#graphql-comma"
491 | },
492 | {
493 | "include": "#literal-quasi-embedded"
494 | }
495 | ]
496 | }
497 | ]
498 | },
499 | "graphql-scalar": {
500 | "match": "\\s*\\b(scalar)\\b\\s*([_A-Za-z][_0-9A-Za-z]*)",
501 | "captures": {
502 | "1": {
503 | "name": "keyword.scalar.graphql"
504 | },
505 | "2": {
506 | "name": "entity.scalar.graphql"
507 | }
508 | }
509 | },
510 | "graphql-scalar-type": {
511 | "match": "\\s*\\b(Int|Float|String|Boolean|ID)\\b(?:\\s*(!))?",
512 | "captures": {
513 | "1": {
514 | "name": "support.type.builtin.graphql"
515 | },
516 | "2": {
517 | "name": "keyword.operator.nulltype.graphql"
518 | }
519 | }
520 | },
521 | "graphql-variable-assignment": {
522 | "begin": "\\s(=)",
523 | "end": "(?=[\n,)])",
524 | "applyEndPatternLast": 1,
525 | "beginCaptures": {
526 | "1": {
527 | "name": "punctuation.assignment.graphql"
528 | }
529 | },
530 | "patterns": [
531 | {
532 | "include": "#graphql-value"
533 | }
534 | ]
535 | },
536 | "graphql-comma": {
537 | "match": "\\s*(,)",
538 | "captures": {
539 | "1": {
540 | "name": "punctuation.comma.graphql"
541 | }
542 | }
543 | },
544 | "graphql-colon": {
545 | "match": "\\s*(:)",
546 | "captures": {
547 | "1": {
548 | "name": "punctuation.colon.graphql"
549 | }
550 | }
551 | },
552 | "graphql-union-mark": {
553 | "match": "\\s*(\\|)",
554 | "captures": {
555 | "1": {
556 | "name": "punctuation.union.graphql"
557 | }
558 | }
559 | },
560 | "graphql-name": {
561 | "match": "\\s*([_A-Za-z][_0-9A-Za-z]*)",
562 | "captures": {
563 | "1": {
564 | "name": "entity.name.function.graphql"
565 | }
566 | }
567 | },
568 | "graphql-directive": {
569 | "begin": "\\s*((@)\\s*([_A-Za-z][_0-9A-Za-z]*))",
570 | "end": "(?=.)",
571 | "applyEndPatternLast": 1,
572 | "beginCaptures": {
573 | "1": {
574 | "name": "entity.name.function.directive.graphql"
575 | }
576 | },
577 | "patterns": [
578 | {
579 | "include": "#graphql-arguments"
580 | },
581 | {
582 | "include": "#graphql-comment"
583 | },
584 | {
585 | "include": "#literal-quasi-embedded"
586 | },
587 | {
588 | "include": "#graphql-skip-newlines"
589 | }
590 | ]
591 | },
592 | "graphql-selection-set": {
593 | "name": "meta.selectionset.graphql",
594 | "begin": "\\s*({)",
595 | "end": "\\s*(})",
596 | "beginCaptures": {
597 | "1": {
598 | "name": "punctuation.operation.graphql"
599 | }
600 | },
601 | "endCaptures": {
602 | "1": {
603 | "name": "punctuation.operation.graphql"
604 | }
605 | },
606 | "patterns": [
607 | {
608 | "include": "#graphql-field"
609 | },
610 | {
611 | "include": "#graphql-fragment-spread"
612 | },
613 | {
614 | "include": "#graphql-inline-fragment"
615 | },
616 | {
617 | "include": "#graphql-comma"
618 | },
619 | {
620 | "include": "#graphql-comment"
621 | },
622 | {
623 | "include": "#native-interpolation"
624 | },
625 | {
626 | "include": "#literal-quasi-embedded"
627 | }
628 | ]
629 | },
630 | "graphql-field": {
631 | "patterns": [
632 | {
633 | "match": "\\s*([_A-Za-z][_0-9A-Za-z]*)\\s*(:)",
634 | "captures": {
635 | "1": {
636 | "name": "string.unquoted.alias.graphql"
637 | },
638 | "2": {
639 | "name": "punctuation.colon.graphql"
640 | }
641 | }
642 | },
643 | {
644 | "match": "\\s*([_A-Za-z][_0-9A-Za-z]*)",
645 | "captures": {
646 | "1": {
647 | "name": "variable.graphql"
648 | }
649 | }
650 | },
651 | {
652 | "include": "#graphql-arguments"
653 | },
654 | {
655 | "include": "#graphql-directive"
656 | },
657 | {
658 | "include": "#graphql-selection-set"
659 | },
660 | {
661 | "include": "#literal-quasi-embedded"
662 | },
663 | {
664 | "include": "#graphql-skip-newlines"
665 | }
666 | ]
667 | },
668 | "graphql-fragment-spread": {
669 | "begin": "\\s*(\\.\\.\\.)\\s*(?!\\bon\\b)([_A-Za-z][_0-9A-Za-z]*)",
670 | "end": "(?=.)",
671 | "applyEndPatternLast": 1,
672 | "captures": {
673 | "1": {
674 | "name": "keyword.operator.spread.graphql"
675 | },
676 | "2": {
677 | "name": "variable.fragment.graphql"
678 | }
679 | },
680 | "patterns": [
681 | {
682 | "include": "#graphql-comment"
683 | },
684 | {
685 | "include": "#graphql-selection-set"
686 | },
687 | {
688 | "include": "#graphql-directive"
689 | },
690 | {
691 | "include": "#literal-quasi-embedded"
692 | },
693 | {
694 | "include": "#graphql-skip-newlines"
695 | }
696 | ]
697 | },
698 | "graphql-inline-fragment": {
699 | "begin": "\\s*(\\.\\.\\.)\\s*(?:(\\bon\\b)\\s*([_A-Za-z][_0-9A-Za-z]*))?",
700 | "end": "(?=.)",
701 | "applyEndPatternLast": 1,
702 | "captures": {
703 | "1": {
704 | "name": "keyword.operator.spread.graphql"
705 | },
706 | "2": {
707 | "name": "keyword.on.graphql"
708 | },
709 | "3": {
710 | "name": "support.type.graphql"
711 | }
712 | },
713 | "patterns": [
714 | {
715 | "include": "#graphql-comment"
716 | },
717 | {
718 | "include": "#graphql-selection-set"
719 | },
720 | {
721 | "include": "#graphql-directive"
722 | },
723 | {
724 | "include": "#graphql-skip-newlines"
725 | },
726 | {
727 | "include": "#literal-quasi-embedded"
728 | }
729 | ]
730 | },
731 | "graphql-arguments": {
732 | "name": "meta.arguments.graphql",
733 | "begin": "\\s*(\\()",
734 | "end": "\\s*(\\))",
735 | "beginCaptures": {
736 | "1": {
737 | "name": "meta.brace.round.directive.graphql"
738 | }
739 | },
740 | "endCaptures": {
741 | "1": {
742 | "name": "meta.brace.round.directive.graphql"
743 | }
744 | },
745 | "patterns": [
746 | {
747 | "include": "#graphql-comment"
748 | },
749 | {
750 | "begin": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?:\\s*(:))",
751 | "end": "(?=\\s*(?:(?:([_A-Za-z][_0-9A-Za-z]*)\\s*(:))|\\)))|\\s*(,)",
752 | "beginCaptures": {
753 | "1": {
754 | "name": "variable.parameter.graphql"
755 | },
756 | "2": {
757 | "name": "punctuation.colon.graphql"
758 | }
759 | },
760 | "endCaptures": {
761 | "3": {
762 | "name": "punctuation.comma.graphql"
763 | }
764 | },
765 | "patterns": [
766 | {
767 | "include": "#graphql-value"
768 | },
769 | {
770 | "include": "#graphql-comment"
771 | },
772 | {
773 | "include": "#graphql-skip-newlines"
774 | }
775 | ]
776 | },
777 | {
778 | "include": "#literal-quasi-embedded"
779 | }
780 | ]
781 | },
782 | "graphql-variable-name": {
783 | "match": "\\s*(\\$[_A-Za-z][_0-9A-Za-z]*)",
784 | "captures": {
785 | "1": {
786 | "name": "variable.graphql"
787 | }
788 | }
789 | },
790 | "graphql-float-value": {
791 | "match": "\\s*(-?(0|[1-9][0-9]*)(\\.[0-9]+)?((e|E)(\\+|-)?[0-9]+)?)",
792 | "captures": {
793 | "1": {
794 | "name": "constant.numeric.float.graphql"
795 | }
796 | }
797 | },
798 | "graphql-boolean-value": {
799 | "match": "\\s*\\b(true|false)\\b",
800 | "captures": {
801 | "1": {
802 | "name": "constant.language.boolean.graphql"
803 | }
804 | }
805 | },
806 | "graphql-null-value": {
807 | "match": "\\s*\\b(null)\\b",
808 | "captures": {
809 | "1": {
810 | "name": "constant.language.null.graphql"
811 | }
812 | }
813 | },
814 | "graphql-string-value": {
815 | "contentName": "string.quoted.double.graphql",
816 | "begin": "\\s*+((\"))",
817 | "end": "\\s*+(?:((\"))|(\n))",
818 | "beginCaptures": {
819 | "1": {
820 | "name": "string.quoted.double.graphql"
821 | },
822 | "2": {
823 | "name": "punctuation.definition.string.begin.graphql"
824 | }
825 | },
826 | "endCaptures": {
827 | "1": {
828 | "name": "string.quoted.double.graphql"
829 | },
830 | "2": {
831 | "name": "punctuation.definition.string.end.graphql"
832 | },
833 | "3": {
834 | "name": "invalid.illegal.newline.graphql"
835 | }
836 | },
837 | "patterns": [
838 | {
839 | "include": "#graphql-string-content"
840 | },
841 | {
842 | "include": "#literal-quasi-embedded"
843 | }
844 | ]
845 | },
846 | "graphql-string-content": {
847 | "patterns": [
848 | {
849 | "name": "constant.character.escape.graphql",
850 | "match": "\\\\[/'\"\\\\nrtbf]"
851 | },
852 | {
853 | "name": "constant.character.escape.graphql",
854 | "match": "\\\\u([0-9a-fA-F]{4})"
855 | }
856 | ]
857 | },
858 | "graphql-enum": {
859 | "name": "meta.enum.graphql",
860 | "begin": "\\s*+\\b(enum)\\b\\s*([_A-Za-z][_0-9A-Za-z]*)",
861 | "end": "(?<=})",
862 | "beginCaptures": {
863 | "1": {
864 | "name": "keyword.enum.graphql"
865 | },
866 | "2": {
867 | "name": "support.type.enum.graphql"
868 | }
869 | },
870 | "patterns": [
871 | {
872 | "name": "meta.type.object.graphql",
873 | "begin": "\\s*({)",
874 | "end": "\\s*(})",
875 | "beginCaptures": {
876 | "1": {
877 | "name": "punctuation.operation.graphql"
878 | }
879 | },
880 | "endCaptures": {
881 | "1": {
882 | "name": "punctuation.operation.graphql"
883 | }
884 | },
885 | "patterns": [
886 | {
887 | "include": "#graphql-object-type"
888 | },
889 | {
890 | "include": "#graphql-comment"
891 | },
892 | {
893 | "include": "#graphql-enum-value"
894 | },
895 | {
896 | "include": "#literal-quasi-embedded"
897 | }
898 | ]
899 | }
900 | ]
901 | },
902 | "graphql-enum-value": {
903 | "name": "constant.character.enum.graphql",
904 | "match": "\\s*(?!=\\b(true|false|null)\\b)([_A-Za-z][_0-9A-Za-z]*)"
905 | },
906 | "graphql-value": {
907 | "patterns": [
908 | {
909 | "include": "#graphql-variable-name"
910 | },
911 | {
912 | "include": "#graphql-float-value"
913 | },
914 | {
915 | "include": "#graphql-string-value"
916 | },
917 | {
918 | "include": "#graphql-boolean-value"
919 | },
920 | {
921 | "include": "#graphql-null-value"
922 | },
923 | {
924 | "include": "#graphql-enum-value"
925 | },
926 | {
927 | "include": "#graphql-list-value"
928 | },
929 | {
930 | "include": "#graphql-object-value"
931 | },
932 | {
933 | "include": "#graphql-comment"
934 | },
935 | {
936 | "include": "#literal-quasi-embedded"
937 | }
938 | ]
939 | },
940 | "graphql-list-value": {
941 | "patterns": [
942 | {
943 | "name": "meta.listvalues.graphql",
944 | "begin": "\\s*+(\\[)",
945 | "end": "\\s*(\\])",
946 | "endCaptures": {
947 | "1": {
948 | "name": "meta.brace.square.graphql"
949 | }
950 | },
951 | "beginCaptures": {
952 | "1": {
953 | "name": "meta.brace.square.graphql"
954 | }
955 | },
956 | "patterns": [
957 | {
958 | "include": "#graphql-value"
959 | }
960 | ]
961 | }
962 | ]
963 | },
964 | "graphql-object-value": {
965 | "patterns": [
966 | {
967 | "name": "meta.objectvalues.graphql",
968 | "begin": "\\s*+({)",
969 | "end": "\\s*(})",
970 | "beginCaptures": {
971 | "1": {
972 | "name": "meta.brace.curly.graphql"
973 | }
974 | },
975 | "endCaptures": {
976 | "1": {
977 | "name": "meta.brace.curly.graphql"
978 | }
979 | },
980 | "patterns": [
981 | {
982 | "include": "#graphql-object-field"
983 | },
984 | {
985 | "include": "#graphql-value"
986 | }
987 | ]
988 | }
989 | ]
990 | },
991 | "graphql-object-field": {
992 | "match": "\\s*(([_A-Za-z][_0-9A-Za-z]*))\\s*(:)",
993 | "captures": {
994 | "1": {
995 | "name": "constant.object.key.graphql"
996 | },
997 | "2": {
998 | "name": "string.unquoted.graphql"
999 | },
1000 | "3": {
1001 | "name": "punctuation.graphql"
1002 | }
1003 | }
1004 | },
1005 | "graphql-union": {
1006 | "begin": "\\s*\\b(union)\\b\\s*([_A-Za-z][_0-9A-Za-z]*)",
1007 | "end": "(?=.)",
1008 | "applyEndPatternLast": 1,
1009 | "captures": {
1010 | "1": {
1011 | "name": "keyword.union.graphql"
1012 | },
1013 | "2": {
1014 | "name": "support.type.graphql"
1015 | }
1016 | },
1017 | "patterns": [
1018 | {
1019 | "begin": "\\s*(=)\\s*([_A-Za-z][_0-9A-Za-z]*)",
1020 | "end": "(?=.)",
1021 | "applyEndPatternLast": 1,
1022 | "captures": {
1023 | "1": {
1024 | "name": "punctuation.assignment.graphql"
1025 | },
1026 | "2": {
1027 | "name": "support.type.graphql"
1028 | }
1029 | },
1030 | "patterns": [
1031 | {
1032 | "include": "#graphql-skip-newlines"
1033 | },
1034 | {
1035 | "include": "#graphql-comment"
1036 | },
1037 | {
1038 | "include": "#literal-quasi-embedded"
1039 | },
1040 | {
1041 | "match": "\\s*(\\|)\\s*([_A-Za-z][_0-9A-Za-z]*)",
1042 | "captures": {
1043 | "1": {
1044 | "name": "punctuation.or.graphql"
1045 | },
1046 | "2": {
1047 | "name": "support.type.graphql"
1048 | }
1049 | }
1050 | }
1051 | ]
1052 | },
1053 | {
1054 | "include": "#graphql-skip-newlines"
1055 | },
1056 | {
1057 | "include": "#graphql-comment"
1058 | },
1059 | {
1060 | "include": "#literal-quasi-embedded"
1061 | }
1062 | ]
1063 | },
1064 | "native-interpolation": {
1065 | "name": "native.interpolation",
1066 | "begin": "\\s*(\\${)",
1067 | "end": "(})",
1068 | "beginCaptures": {
1069 | "1": {
1070 | "name": "keyword.other.substitution.begin"
1071 | }
1072 | },
1073 | "endCaptures": {
1074 | "1": {
1075 | "name": "keyword.other.substitution.end"
1076 | }
1077 | },
1078 | "patterns": [
1079 | {
1080 | "include": "source.js"
1081 | },
1082 | {
1083 | "include": "source.ts"
1084 | },
1085 | {
1086 | "include": "source.jsx"
1087 | },
1088 | {
1089 | "include": "source.tsx"
1090 | }
1091 | ]
1092 | },
1093 | "graphql-skip-newlines": {
1094 | "match": "\\s*\n"
1095 | }
1096 | }
1097 | }
1098 |
--------------------------------------------------------------------------------
/syntaxes/graphql.res.json:
--------------------------------------------------------------------------------
1 | {
2 | "fileTypes": ["res", "resi"],
3 | "injectionSelector": "L:source -string -comment",
4 | "patterns": [
5 | {
6 | "contentName": "meta.embedded.block.graphql",
7 | "begin": "(%relay\\()\\s*$",
8 | "end": "(?<=\\))",
9 | "patterns": [
10 | {
11 | "begin": "^\\s*(`)$",
12 | "end": "^\\s*(`)",
13 | "patterns": [{ "include": "source.graphql" }]
14 | }
15 | ]
16 | },
17 | {
18 | "contentName": "meta.embedded.block.graphql",
19 | "begin": "(%relay\\(`)",
20 | "end": "(\\`( )?\\))",
21 | "patterns": [{ "include": "source.graphql" }]
22 | }
23 | ],
24 | "scopeName": "inline.graphql.rescript"
25 | }
26 |
--------------------------------------------------------------------------------
/syntaxes/rescriptRelayRouter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "RescriptRelayRouter",
3 | "scopeName": "source.rescriptRelayRouter",
4 | "patterns": [
5 | {
6 | "include": "#value"
7 | }
8 | ],
9 | "repository": {
10 | "array": {
11 | "begin": "\\[",
12 | "beginCaptures": {
13 | "0": {
14 | "name": "punctuation.definition.array.begin.json"
15 | }
16 | },
17 | "end": "\\]",
18 | "endCaptures": {
19 | "0": {
20 | "name": "punctuation.definition.array.end.json"
21 | }
22 | },
23 | "name": "meta.structure.array.json",
24 | "patterns": [
25 | {
26 | "include": "#value"
27 | },
28 | {
29 | "match": ",",
30 | "name": "punctuation.separator.array.json"
31 | },
32 | {
33 | "match": "[^\\s\\]]",
34 | "name": "invalid.illegal.expected-array-separator.json"
35 | }
36 | ]
37 | },
38 | "comments": {
39 | "patterns": [
40 | {
41 | "begin": "/\\*\\*(?!/)",
42 | "captures": {
43 | "0": {
44 | "name": "punctuation.definition.comment.json"
45 | }
46 | },
47 | "end": "\\*/",
48 | "name": "comment.block.documentation.json"
49 | },
50 | {
51 | "begin": "/\\*",
52 | "captures": {
53 | "0": {
54 | "name": "punctuation.definition.comment.json"
55 | }
56 | },
57 | "end": "\\*/",
58 | "name": "comment.block.json"
59 | },
60 | {
61 | "captures": {
62 | "1": {
63 | "name": "punctuation.definition.comment.json"
64 | }
65 | },
66 | "match": "(//).*$\\n?",
67 | "name": "comment.line.double-slash.js"
68 | }
69 | ]
70 | },
71 | "constant": {
72 | "match": "\\b(?:true|false|null)\\b",
73 | "name": "constant.language.json"
74 | },
75 | "object": {
76 | "begin": "\\{",
77 | "beginCaptures": {
78 | "0": {
79 | "name": "punctuation.definition.dictionary.begin.json"
80 | }
81 | },
82 | "end": "\\}",
83 | "endCaptures": {
84 | "0": {
85 | "name": "punctuation.definition.dictionary.end.json"
86 | }
87 | },
88 | "name": "meta.structure.dictionary.json",
89 | "patterns": [
90 | {
91 | "begin": "(\"name\":)",
92 | "beginCaptures": {
93 | "1": {
94 | "name": "support.type.property-name.json"
95 | }
96 | },
97 | "end": "(,)|(?=\\})",
98 | "name": "string.json support.type.property-name.json",
99 | "patterns": [
100 | {
101 | "begin": "\"",
102 | "beginCaptures": {
103 | "0": {
104 | "name": "punctuation.definition.string.begin.json"
105 | }
106 | },
107 | "end": "\"",
108 | "endCaptures": {
109 | "0": {
110 | "name": "punctuation.definition.string.end.json"
111 | }
112 | },
113 | "name": "string.quoted.double.json",
114 | "patterns": [
115 | {
116 | "match": ".",
117 | "name": "string.quoted.double.json"
118 | }
119 | ]
120 | }
121 | ]
122 | },
123 | {
124 | "begin": "(\"path\":)",
125 | "beginCaptures": {
126 | "1": {
127 | "name": "support.type.property-name.json"
128 | }
129 | },
130 | "end": "(,)|(?=\\})",
131 | "name": "string.json support.type.property-name.json",
132 | "patterns": [
133 | {
134 | "begin": "\"",
135 | "beginCaptures": {
136 | "0": {
137 | "name": "punctuation.definition.string.begin.json"
138 | }
139 | },
140 | "end": "\"",
141 | "endCaptures": {
142 | "0": {
143 | "name": "punctuation.definition.string.end.json"
144 | }
145 | },
146 | "name": "string.quoted.double.json",
147 | "patterns": [
148 | {
149 | "match": "[/.=&]",
150 | "name": "punctuation.definition.tag"
151 | },
152 | {
153 | "match": "(:[a-z][A-Za-z0-9_]+)",
154 | "name": "variable.object.property"
155 | },
156 | {
157 | "match": "[\\?]",
158 | "name": "keyword.operator"
159 | },
160 | {
161 | "match": "([a-z0-9A-Z_]+)(=)([a-z0-9A-Z\\._<>]+)",
162 | "captures": {
163 | "1": {
164 | "name": "variable.object.property"
165 | },
166 | "2": {
167 | "name": "punctuation.definition.tag"
168 | },
169 | "3": {
170 | "name": "support.type",
171 | "patterns": [
172 | {
173 | "match": "[/.=&<>]",
174 | "name": "punctuation.definition.tag"
175 | }
176 | ]
177 | }
178 | }
179 | }
180 | ]
181 | }
182 | ]
183 | },
184 | {
185 | "comment": "the JSON object key",
186 | "include": "#objectkey"
187 | },
188 | {
189 | "include": "#comments"
190 | },
191 | {
192 | "begin": ":",
193 | "beginCaptures": {
194 | "0": {
195 | "name": "punctuation.separator.dictionary.key-value.json"
196 | }
197 | },
198 | "end": "(,)|(?=\\})",
199 | "endCaptures": {
200 | "1": {
201 | "name": "punctuation.separator.dictionary.pair.json"
202 | }
203 | },
204 | "name": "meta.structure.dictionary.value.json",
205 | "patterns": [
206 | {
207 | "comment": "the JSON object value",
208 | "include": "#value"
209 | },
210 | {
211 | "match": "[^\\s,]",
212 | "name": "invalid.illegal.expected-dictionary-separator.json"
213 | }
214 | ]
215 | },
216 | {
217 | "match": "[^\\s\\}]",
218 | "name": "invalid.illegal.expected-dictionary-separator.json"
219 | }
220 | ]
221 | },
222 | "string": {
223 | "begin": "\"",
224 | "beginCaptures": {
225 | "0": {
226 | "name": "punctuation.definition.string.begin.json"
227 | }
228 | },
229 | "end": "\"",
230 | "endCaptures": {
231 | "0": {
232 | "name": "punctuation.definition.string.end.json"
233 | }
234 | },
235 | "name": "string.quoted.double.json",
236 | "patterns": [
237 | {
238 | "include": "#stringcontent"
239 | }
240 | ]
241 | },
242 | "objectkey": {
243 | "begin": "\"",
244 | "beginCaptures": {
245 | "0": {
246 | "name": "punctuation.support.type.property-name.begin.json"
247 | }
248 | },
249 | "end": "\"",
250 | "endCaptures": {
251 | "0": {
252 | "name": "punctuation.support.type.property-name.end.json"
253 | }
254 | },
255 | "name": "string.json support.type.property-name.json",
256 | "patterns": [
257 | {
258 | "include": "#stringcontent"
259 | }
260 | ]
261 | },
262 |
263 | "stringcontent": {
264 | "patterns": [
265 | {
266 | "match": "(?x) # turn on extended mode\n \\\\ # a literal backslash\n (?: # ...followed by...\n [\"\\\\/bfnrt] # one of these characters\n | # ...or...\n u # a u\n [0-9a-fA-F]{4}) # and four hex digits",
267 | "name": "constant.character.escape.json"
268 | },
269 | {
270 | "match": "\\\\.",
271 | "name": "invalid.illegal.unrecognized-string-escape.json"
272 | }
273 | ]
274 | },
275 | "value": {
276 | "patterns": [
277 | {
278 | "include": "#constant"
279 | },
280 | {
281 | "include": "#number"
282 | },
283 | {
284 | "include": "#string"
285 | },
286 | {
287 | "include": "#array"
288 | },
289 | {
290 | "include": "#object"
291 | },
292 | {
293 | "include": "#comments"
294 | }
295 | ]
296 | }
297 | }
298 | }
299 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "esnext",
5 | "outDir": "build",
6 | "moduleResolution": "node",
7 | "lib": ["dom", "es2017", "esnext"],
8 | "types": ["node", "jest"],
9 | "sourceMap": false,
10 | "esModuleInterop": true,
11 | "removeComments": true,
12 | "noImplicitAny": true,
13 | "noUnusedLocals": true,
14 | "noUnusedParameters": true,
15 | "strict": true
16 | },
17 | "include": ["src"]
18 | }
19 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | // Not used right now
2 | const path = require("path");
3 |
4 | const isProd = process.env.NODE_ENV === "production";
5 |
6 | const config = {
7 | target: "node",
8 | entry: {
9 | extension: "./src/extension.ts",
10 | server: "./src/server.ts"
11 | },
12 | output: {
13 | path: path.resolve(__dirname, "build"),
14 | filename: "[name].js",
15 | libraryTarget: "commonjs2"
16 | },
17 | devtool: "source-map",
18 | externals: {
19 | vscode: "commonjs vscode",
20 | "vscode-languageserver": "vscode-languageserver",
21 | "vscode-languageserver-protocol": "vscode-languageserver-protocol",
22 | encoding: "encoding"
23 | },
24 | resolve: {
25 | extensions: [".mjs", ".js", ".ts"]
26 | },
27 | module: {
28 | rules: [
29 | {
30 | test: /\.ts$/,
31 | exclude: /node_modules/,
32 | use: [
33 | {
34 | loader: "ts-loader",
35 | options: {
36 | compilerOptions: {
37 | module: "es6"
38 | }
39 | }
40 | }
41 | ]
42 | }
43 | ]
44 | }
45 | };
46 |
47 | module.exports = config;
48 |
--------------------------------------------------------------------------------