-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support ES6 tagged template literals
This patch adds support for GraphQL syntax in ES6 tagged template literals. (As used by `graphql-tag`, for example.) By default, GraphQL syntax is highlighted in template literals tagged with `gql` or `graphql`. This can be configured via the `g:graphql_tag_names` array.
- Loading branch information
Showing
2 changed files
with
21 additions
and
0 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,18 @@ | ||
" Prologue; load in GraphQL syntax. | ||
if exists('b:current_syntax') | ||
let s:current_syntax=b:current_syntax | ||
unlet b:current_syntax | ||
endif | ||
syn include @GraphQLSyntax syntax/graphql.vim | ||
if exists('s:current_syntax') | ||
let b:current_syntax=s:current_syntax | ||
endif | ||
|
||
syntax region graphqlTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=@GraphQLSyntax,jsTemplateVar,jsSpecial extend | ||
exec 'syntax match graphqlTaggedTemplate +\%(' . join(g:graphql_tag_names, '\|') . '\)\%(`\)\@=+ nextgroup=graphqlTemplateString' | ||
|
||
hi def link graphqlTemplateString jsTemplateString | ||
hi def link graphqlTaggedTemplate jsTaggedTemplate | ||
|
||
syn cluster jsExpression add=graphqlTaggedTemplate | ||
syn cluster graphqlTaggedTemplate add=graphqlTemplateString |
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,3 @@ | ||
if (!exists('g:graphql_tag_names')) | ||
let g:graphql_tag_names = ['gql', 'graphql'] | ||
endif |