-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ES6 tagged template literals #1
Conversation
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.
This looks good, @paulrosania! I just have a couple of questions:
|
Also, since this introduces a new configuration option ( |
👋🏼 Hi! Does this feel like a valid use case for including the feature in |
Thanks for the pointer! Yes, I think it makes sense to include this in |
+1 |
endif | ||
|
||
syntax region graphqlTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=@GraphQLSyntax,jsTemplateVar,jsSpecial extend | ||
exec 'syntax match graphqlTaggedTemplate +\%(' . join(g:graphql_tag_names, '\|') . '\)\%(`\)\@=+ nextgroup=graphqlTemplateString' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should allow an optional space between tag name and template string.
@paulrosania, anything I can do to help? |
Sorry for the delay on this – I intend to complete the patch but I haven't On Mon, Oct 31, 2016 at 8:07 AM, Jon Parise [email protected]
|
@paulrosania, no rush at all. I just wanted to check in on progress and offer help as needed. |
This kinda works for me: mkdir -p ~/.vim/after/syntax/javascript/ ~/.vim/plugin/
wget https://github.com/paulrosania/vim-graphql/raw/tagged-template-literals/after/syntax/javascript/graphql.vim -O ~/.vim/after/syntax/javascript/graphql.vim
wget https://github.com/paulrosania/vim-graphql/raw/tagged-template-literals/plugin/graphql.vim -O ~/.vim/plugin/graphql.vim It doesn't seem to highlight template literal interpolations as javascript espressions, though, it still scans them with the graphql syntax. I also added |
let b:current_syntax=s:current_syntax | ||
endif | ||
|
||
syntax region graphqlTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=@GraphQLSyntax,jsTemplateVar,jsSpecial extend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/jsTemplateVar/sTemplateExpression/
since pangloss/vim-javascript@88c85d9.
I'll create a branch that includes this original work plus some follow-on changes soon. |
Building on #1, this commit makes the following minor changes: 1. `g:graphql_tag_names` => `g:graphql_javascript_tags` 2. `jsTemplateVar` => `jsTemplateExpression`, to reflect the change made in pangloss/vim-javascript@88c85d9 3. Added `Relay.QL` to the list of recognized JavaScript tags
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 withgql
orgraphql
. This can be configured via theg:graphql_tag_names
array.Note: this feature ties into vim-javascript's syntax groups, so it requires vim-javascript to work correctly. (If vim-javascript is missing, it should be ineffective and harmless.)