summaryrefslogtreecommitdiffstats
path: root/after
diff options
context:
space:
mode:
Diffstat (limited to 'after')
-rw-r--r--after/ftdetect/javascript.vim24
-rw-r--r--after/indent/jsx.vim7
-rw-r--r--after/jsx-config.vim37
-rw-r--r--after/syntax/jsx.vim25
-rw-r--r--after/syntax/rust.vim8
5 files changed, 20 insertions, 81 deletions
diff --git a/after/ftdetect/javascript.vim b/after/ftdetect/javascript.vim
deleted file mode 100644
index a0de1b1f..00000000
--- a/after/ftdetect/javascript.vim
+++ /dev/null
@@ -1,24 +0,0 @@
-if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" Vim ftdetect file
-"
-" Language: JSX (JavaScript)
-" Maintainer: Max Wang <mxawng@gmail.com>
-"
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
-exec 'source '.fnameescape(expand('<sfile>:p:h:h').'/jsx-config.vim')
-
-fu! <SID>EnableJSX()
- if g:jsx_pragma_required && !b:jsx_pragma_found | return 0 | endif
- if g:jsx_ext_required && !exists('b:jsx_ext_found') | return 0 | endif
- return 1
-endfu
-
-autocmd BufNewFile,BufRead *.jsx let b:jsx_ext_found = 1
-autocmd BufNewFile,BufRead *.jsx set filetype=javascript.jsx
-autocmd BufNewFile,BufRead *.js
- \ if <SID>EnableJSX() | set filetype=javascript.jsx | endif
-
-endif
diff --git a/after/indent/jsx.vim b/after/indent/jsx.vim
index d33c13dd..f4c36662 100644
--- a/after/indent/jsx.vim
+++ b/after/indent/jsx.vim
@@ -9,13 +9,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" 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 indentation.
if exists('b:did_indent')
let s:did_indent=b:did_indent
diff --git a/after/jsx-config.vim b/after/jsx-config.vim
deleted file mode 100644
index 0303fb0c..00000000
--- a/after/jsx-config.vim
+++ /dev/null
@@ -1,37 +0,0 @@
-if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" Vimscript file
-"
-" Set up a bunch of configuration variables.
-"
-" Also check (if desired) whether or not the @jsx pragma is correctly included
-" in '%'. Set the result in b:jsx_pragma_found.
-"
-" Language: JSX (JavaScript)
-" Maintainer: Max Wang <mxawng@gmail.com>
-"
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
-" Only check once.
-if exists('b:jsx_pragma_found')
- finish
-endif
-
-" Whether the .jsx extension is required to enable JSX syntax/indent.
-if !exists('g:jsx_ext_required')
- let g:jsx_ext_required = 1
-endif
-
-" Whether the @jsx pragma is required to enable JSX syntax/indent.
-if !exists('g:jsx_pragma_required')
- let g:jsx_pragma_required = 0
-endif
-if !g:jsx_pragma_required | finish | endif
-
-" Look for the @jsx pragma. It must be included in a docblock comment before
-" anything else in the file (except whitespace).
-let s:jsx_pragma_pattern = '\%^\_s*\/\*\*\%(\_.\%(\*\/\)\@!\)*@jsx\_.\{-}\*\/'
-let b:jsx_pragma_found = search(s:jsx_pragma_pattern, 'npw')
-
-endif
diff --git a/after/syntax/jsx.vim b/after/syntax/jsx.vim
index 7efb05bd..0aafca12 100644
--- a/after/syntax/jsx.vim
+++ b/after/syntax/jsx.vim
@@ -11,13 +11,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" 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
@@ -28,9 +21,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=+/>+
@@ -45,7 +53,6 @@ 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
endif
diff --git a/after/syntax/rust.vim b/after/syntax/rust.vim
index 5748c4df..cb13cd73 100644
--- a/after/syntax/rust.vim
+++ b/after/syntax/rust.vim
@@ -1,11 +1,11 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1
-if !exists('g:rust_conceal') || !has('conceal') || &enc != 'utf-8'
+if !exists('g:rust_conceal') || g:rust_conceal == 0 || !has('conceal') || &enc != 'utf-8'
finish
endif
" For those who don't want to see `::`...
-if exists('g:rust_conceal_mod_path')
+if exists('g:rust_conceal_mod_path') && g:rust_conceal_mod_path != 0
syn match rustNiceOperator "::" conceal cchar=ㆍ
endif
@@ -20,7 +20,7 @@ syn match rustNiceOperator "=>" contains=rustFatRightArrowHead,rustFatRightArrow
syn match rustNiceOperator /\<\@!_\(_*\>\)\@=/ conceal cchar=′
" For those who don't want to see `pub`...
-if exists('g:rust_conceal_pub')
+if exists('g:rust_conceal_pub') && g:rust_conceal_pub != 0
syn match rustPublicSigil contained "pu" conceal cchar=*
syn match rustPublicRest contained "b" conceal cchar= 
syn match rustNiceOperator "pub " contains=rustPublicSigil,rustPublicRest
@@ -28,7 +28,7 @@ endif
hi link rustNiceOperator Operator
-if !exists('g:rust_conceal_mod_path')
+if !exists('g:rust_conceal_mod_path') && g:rust_conceal_mod_path != 0
hi! link Conceal Operator
endif