diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2019-06-08 14:12:14 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2019-06-08 14:12:14 +0200 |
commit | 445e0260108fbc5745d77b6e15b290eb55d4f1b2 (patch) | |
tree | 69081d77ae4fb1da4566cdc2b56c739270287f0d /after/ftplugin/javascript.vim | |
parent | fca45b2c2b9ed9d07f6d5014c8c3ef8f2f22c964 (diff) | |
download | vim-polyglot-3.9.0.tar.gz vim-polyglot-3.9.0.zip |
Add styled-components, closes #407v3.9.0
Diffstat (limited to 'after/ftplugin/javascript.vim')
-rw-r--r-- | after/ftplugin/javascript.vim | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/after/ftplugin/javascript.vim b/after/ftplugin/javascript.vim index 26d00bf2..093f0b7b 100644 --- a/after/ftplugin/javascript.vim +++ b/after/ftplugin/javascript.vim @@ -49,3 +49,40 @@ augroup jsx_comment augroup end setlocal suffixesadd+=.jsx +if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'styled-components') != -1 + finish +endif + +" Vim filetype plugin file +" Language: styled-components (js/ts) +" Maintainer: Karl Fleischmann <fleischmann.karl@gmail.com> +" URL: https://github.com/styled-components/vim-styled-components + +fu! s:GetSyntaxNames(lnum, cnum) + return map(synstack(a:lnum, a:cnum), 'synIDattr(v:val, "name")') +endfu + +" re-implement SynSOL of vim-jsx +fu! s:SynSOL(lnum) + return s:GetSyntaxNames(a:lnum, 1) +endfu + +"" Return whether the current line is a jsTemplateString +fu! IsStyledDefinition(lnum) + " iterate through all syntax items in the given line + for item in s:SynSOL(a:lnum) + " if syntax-item is a jsTemplateString return 1 - true + " `==#` is a match case comparison of the item + if item ==# 'styledDefinition' + return 1 + endif + endfor + + " fallback to 0 - false + return 0 +endfu + +if exists('&ofu') + let b:prevofu=&ofu + setl omnifunc=styledcomplete#CompleteSC +endif |