From 1c80c4bb08ae250d2eb19aabe0f31c1b2bdf5097 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sat, 18 Jul 2015 22:50:09 +0200 Subject: Add jsx support, closes #56 --- after/syntax/jsx.vim | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 after/syntax/jsx.vim (limited to 'after/syntax') 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 +" 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(':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=+<\@+ + \ end=++ + \ 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 -- cgit v1.2.3