Permalink
Browse files

Avoid conflict w/ Flow generics

Also add some documentation regarding package compatibility.
1 parent da9b92b commit 80dbab7588c615126f47e50fa4d9c329d080ff95 @mxw committed Nov 25, 2015
Showing with 16 additions and 2 deletions.
  1. +16 −2 after/syntax/jsx.vim
View
@@ -19,9 +19,24 @@ if exists('s:current_syntax')
let b:current_syntax=s:current_syntax
endif
+" Officially, vim-jsx depends on the pangloss/vim-javascript syntax package
+" (and is tested against it exclusively). However, in practice, we make some
+" effort towards compatibility with other packages.
+"
+" These are the plugin-to-syntax-element correspondences:
+"
+" - pangloss/vim-javascript: jsBlock, jsExpression
+" - jelera/vim-javascript-syntax: javascriptBlock
+" - othree/yajs.vim: javascriptNoReserved
+
+
" Highlight JSX regions as XML; recursively match.
+"
+" Note that we prohibit JSX tags from having a < or word character immediately
+" preceding it, to avoid conflicts with, respectively, the left shift operator
+" and generic Flow type annotations (http://flowtype.org/).
syn region jsxRegion contains=@XMLSyntax,jsxRegion,jsBlock,javascriptBlock
- \ start=+<\@<!<\z([a-zA-Z][a-zA-Z0-9:\-.]*\)+
+ \ start=+\%(<\|\w\)\@<!<\z([a-zA-Z][a-zA-Z0-9:\-.]*\)+
\ skip=+<!--\_.\{-}-->+
\ end=+</\z1\_\s\{-}>+
\ end=+/>+
@@ -36,5 +51,4 @@ syn region xmlString contained start=+{+ end=++ contains=jsBlock,javascriptBlock
syn cluster jsExpression add=jsxRegion
" Allow jsxRegion to contain reserved words.
-" See: https://github.com/othree/yajs.vim
syn cluster javascriptNoReserved add=jsxRegion

0 comments on commit 80dbab7

Please sign in to comment.