diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2015-07-18 22:50:09 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2015-07-18 22:50:09 +0200 |
commit | 1c80c4bb08ae250d2eb19aabe0f31c1b2bdf5097 (patch) | |
tree | c7700e4cb18952201fb991a48fb727ba3b9d4287 /after/syntax | |
parent | 548653cafeaa948161ad9ac8184deca0bff95537 (diff) | |
download | vim-polyglot-1c80c4bb08ae250d2eb19aabe0f31c1b2bdf5097.tar.gz vim-polyglot-1c80c4bb08ae250d2eb19aabe0f31c1b2bdf5097.zip |
Add jsx support, closes #56
Diffstat (limited to 'after/syntax')
-rw-r--r-- | after/syntax/jsx.vim | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/after/syntax/jsx.vim b/after/syntax/jsx.vim new file mode 100644 index 00000000..63a1248f --- /dev/null +++ b/after/syntax/jsx.vim @@ -0,0 +1,43 @@ +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Vim syntax file +" +" Language: JSX (JavaScript) +" Maintainer: Max Wang <mxawng@gmail.com> +" Depends: pangloss/vim-javascript +" +" CREDITS: Inspired by Facebook. +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Do nothing if we don't find the @jsx pragma (and we care). +exec 'source '.fnameescape(expand('<sfile>:p:h:h').'/jsx-config.vim') +if g:jsx_pragma_required && !b:jsx_pragma_found | finish | endif + +" Do nothing if we don't have the .jsx extension (and we care). +if g:jsx_ext_required && !exists('b:jsx_ext_found') | finish | endif + +" Prologue; load in XML syntax. +if exists('b:current_syntax') + let s:current_syntax=b:current_syntax + unlet b:current_syntax +endif +syn include @XMLSyntax syntax/xml.vim +if exists('s:current_syntax') + let b:current_syntax=s:current_syntax +endif + +" Highlight JSX regions as XML; recursively match. +syn region jsxRegion contains=@XMLSyntax,jsxRegion,jsBlock,javascriptBlock + \ start=+<\@<!<\z([a-zA-Z][a-zA-Z0-9:\-.]*\)+ + \ skip=+<!--\_.\{-}-->+ + \ end=+</\z1\_\s\{-}>+ + \ end=+/>+ + \ keepend + \ extend + +" JSX attributes should color as JS. Note the trivial end pattern; we let +" jsBlock take care of ending the region. +syn region xmlString contained start=+{+ end=++ contains=jsBlock,javascriptBlock + +" Add jsxRegion to the lowest-level JS syntax cluster. +syn cluster jsExpression add=jsxRegion |