summaryrefslogtreecommitdiffstats
path: root/after/syntax/javascript.vim
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2019-06-08 13:25:41 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2019-06-08 13:25:41 +0200
commit26c678b08d88b658ec6069eb2ada2b2ba21c5d39 (patch)
treeebf7500bafee56b195bf52ced286fe29e5b3f485 /after/syntax/javascript.vim
parent17ecfbdabcfdf294dae27c506fb68b58175199b5 (diff)
downloadvim-polyglot-26c678b08d88b658ec6069eb2ada2b2ba21c5d39.tar.gz
vim-polyglot-26c678b08d88b658ec6069eb2ada2b2ba21c5d39.zip
Change jsx/tsx provider, closes #400
Diffstat (limited to 'after/syntax/javascript.vim')
-rw-r--r--after/syntax/javascript.vim64
1 files changed, 64 insertions, 0 deletions
diff --git a/after/syntax/javascript.vim b/after/syntax/javascript.vim
new file mode 100644
index 00000000..7b92ecbd
--- /dev/null
+++ b/after/syntax/javascript.vim
@@ -0,0 +1,64 @@
+if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jsx') != -1
+ finish
+endif
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Vim syntax file
+"
+" Language: javascript.jsx
+" Maintainer: MaxMellon <maxmellon1994@gmail.com>
+"
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+let s:jsx_cpo = &cpo
+set cpo&vim
+
+syntax case match
+
+if exists('b:current_syntax')
+ let s:current_syntax = b:current_syntax
+ unlet b:current_syntax
+endif
+
+if exists('s:current_syntax')
+ let b:current_syntax = s:current_syntax
+endif
+
+if hlexists("jsNoise") " pangloss/vim-javascript
+ syntax cluster jsExpression add=jsxRegion
+elseif hlexists("javascriptOpSymbols") " othree/yajs.vim
+ " refine the javascript line comment
+ syntax region javascriptLineComment start=+//+ end=/$/ contains=@Spell,javascriptCommentTodo extend keepend
+ syntax cluster javascriptValue add=jsxRegion
+ syntax cluster javascriptNoReserved add=jsxElement,jsxTag
+
+ " add support to arrow function which returns a tagged template string, e.g.
+ " () => html`<div></div>`
+ syntax cluster afterArrowFunc add=javascriptTagRef
+else " build-in javascript syntax
+ " refine the javascript line comment
+ syntax region javaScriptLineComment start=+//+ end=/$/ contains=@Spell,javascriptCommentTodo extend keepend
+ " add a javaScriptBlock group for build-in syntax
+ syntax region javaScriptBlockBuildIn
+ \ contained
+ \ matchgroup=javaScriptBraces
+ \ start="{"
+ \ end="}"
+ \ extend
+ \ contains=javaScriptBlockBuildIn,@javaScriptEmbededExpr,javaScript.*
+ \ fold
+ syntax cluster javaScriptEmbededExpr add=jsxRegion
+
+ " refine the template string syntax
+ syntax region javaScriptStringT start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=javaScriptSpecial,javaScriptEmbed,@htmlPreproc extend
+ syntax region javaScriptEmbed matchgroup=javaScriptEmbedBraces start=+\${+ end=+}+ contained contains=@javaScriptEmbededExpr,javaScript.*
+endif
+
+" because this is autoloaded, when developing you're going to need to source
+" the autoload/jsx_pretty/*.vim file manually, or restart vim
+call jsx_pretty#syntax#highlight()
+
+let b:current_syntax = 'javascript.jsx'
+
+let &cpo = s:jsx_cpo
+unlet s:jsx_cpo