diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2019-09-04 16:29:56 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2019-09-04 16:29:56 +0200 |
commit | 556c56d185fcc7d5cc6d51ea9a6453bcd4f7116c (patch) | |
tree | f97d9f0cdf9df718aaf1a04eed16819a84a5bab2 /after/syntax/javascript/graphql.vim | |
parent | fe84062992e12dea8e090e647afa6b314e891f73 (diff) | |
download | vim-polyglot-556c56d185fcc7d5cc6d51ea9a6453bcd4f7116c.tar.gz vim-polyglot-556c56d185fcc7d5cc6d51ea9a6453bcd4f7116c.zip |
Add graphql support, closes #298
Diffstat (limited to 'after/syntax/javascript/graphql.vim')
-rw-r--r-- | after/syntax/javascript/graphql.vim | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/after/syntax/javascript/graphql.vim b/after/syntax/javascript/graphql.vim new file mode 100644 index 00000000..edc8eea1 --- /dev/null +++ b/after/syntax/javascript/graphql.vim @@ -0,0 +1,27 @@ +if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'graphql') != -1 + finish +endif + +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 + +let s:tags = '\%(' . join(graphql#javascript_tags(), '\|') . '\)' + +exec 'syntax region graphqlTemplateString start=+' . s:tags . '\@20<=`+ skip=+\\`+ end=+`+ contains=@GraphQLSyntax,jsTemplateExpression,jsSpecial extend' +exec 'syntax match graphqlTaggedTemplate +' . s:tags . '\ze`+ nextgroup=graphqlTemplateString' + +" Support expression interpolation ((${...})) inside template strings. +syntax region graphqlTemplateExpression start=+${+ end=+}+ contained contains=jsTemplateExpression containedin=graphqlFold keepend + +hi def link graphqlTemplateString jsTemplateString +hi def link graphqlTaggedTemplate jsTaggedTemplate +hi def link graphqlTemplateExpression jsTemplateExpression + +syn cluster jsExpression add=graphqlTaggedTemplate +syn cluster graphqlTaggedTemplate add=graphqlTemplateString |