summaryrefslogtreecommitdiffstats
path: root/after
diff options
context:
space:
mode:
Diffstat (limited to 'after')
-rw-r--r--after/autoload/styledcomplete.vim42
-rw-r--r--after/syntax/javascript/graphql.vim27
-rw-r--r--after/syntax/typescript/graphql.vim26
3 files changed, 95 insertions, 0 deletions
diff --git a/after/autoload/styledcomplete.vim b/after/autoload/styledcomplete.vim
index efa992c4..d1a8859d 100644
--- a/after/autoload/styledcomplete.vim
+++ b/after/autoload/styledcomplete.vim
@@ -19,3 +19,45 @@ fun! styledcomplete#CompleteSC(findstart, base)
return s:funcref(a:findstart, a:base)
endif
endfun
+if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'styled-components') != -1
+ finish
+endif
+
+" Vim completion script
+" Language: styled-components (js/ts)
+" Maintainer: Karl Fleischmann <fleischmann.karl@gmail.com>
+" URL: https://github.com/styled-components/vim-styled-components
+
+fun! styledcomplete#CompleteSC(findstart, base)
+ if IsStyledDefinition(line('.'))
+ return csscomplete#CompleteCSS(a:findstart, a:base)
+ endif
+
+ " Only trigger original omnifunc if it was set in the first place
+ if exists('b:prevofu')
+ " create a funcref to call with the previous omnicomplete function
+ let s:funcref = function(b:prevofu)
+ return s:funcref(a:findstart, a:base)
+ endif
+endfun
+if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'styled-components') != -1
+ finish
+endif
+
+" Vim completion script
+" Language: styled-components (js/ts)
+" Maintainer: Karl Fleischmann <fleischmann.karl@gmail.com>
+" URL: https://github.com/styled-components/vim-styled-components
+
+fun! styledcomplete#CompleteSC(findstart, base)
+ if IsStyledDefinition(line('.'))
+ return csscomplete#CompleteCSS(a:findstart, a:base)
+ endif
+
+ " Only trigger original omnifunc if it was set in the first place
+ if exists('b:prevofu')
+ " create a funcref to call with the previous omnicomplete function
+ let s:funcref = function(b:prevofu)
+ return s:funcref(a:findstart, a:base)
+ endif
+endfun
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
diff --git a/after/syntax/typescript/graphql.vim b/after/syntax/typescript/graphql.vim
new file mode 100644
index 00000000..fc070daa
--- /dev/null
+++ b/after/syntax/typescript/graphql.vim
@@ -0,0 +1,26 @@
+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,typescriptTemplateSubstitution extend'
+exec 'syntax match graphqlTaggedTemplate +' . s:tags . '\ze`+ nextgroup=graphqlTemplateString'
+
+" Support expression interpolation ((${...})) inside template strings.
+syntax region graphqlTemplateExpression start=+${+ end=+}+ contained contains=typescriptTemplateSubstitution containedin=graphqlFold keepend
+
+hi def link graphqlTemplateString typescriptTemplate
+hi def link graphqlTemplateExpression typescriptTemplateSubstitution
+
+syn cluster typescriptExpression add=graphqlTaggedTemplate
+syn cluster graphqlTaggedTemplate add=graphqlTemplateString