mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-12 05:23:51 -05:00
Change jsx/tsx provider, closes #400
This commit is contained in:
@@ -606,59 +606,6 @@ au BufNewFile,BufRead *.ect set filetype=jst
|
||||
augroup end
|
||||
endif
|
||||
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1
|
||||
augroup filetypedetect
|
||||
" jsx, from javascript.vim in amadeus/vim-jsx
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Vim ftdetect file
|
||||
"
|
||||
" Language: JSX (JavaScript)
|
||||
" Maintainer: Max Wang <mxawng@gmail.com>
|
||||
"
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
let s:jsx_pragma_pattern = '\%^\_s*\/\*\*\%(\_.\%(\*\/\)\@!\)*@jsx\_.\{-}\*\/'
|
||||
|
||||
" if g:jsx_check_react_import == 1
|
||||
" parse the first line of js file (skipping comments). When it has a 'react'
|
||||
" importation, we guess the user writes jsx
|
||||
" endif
|
||||
let s:jsx_prevalent_pattern =
|
||||
\ '\v\C%^\_s*%(%(//.*\_$|/\*\_.{-}\*/)@>\_s*)*%(import\s+\k+\s+from\s+|%(\l+\s+)=\k+\s*\=\s*require\s*\(\s*)[`"'']react>'
|
||||
|
||||
" Whether to set the JSX filetype on *.js files.
|
||||
fu! <SID>EnableJSX()
|
||||
" Whether the .jsx extension is required.
|
||||
if !exists('g:jsx_ext_required')
|
||||
let g:jsx_ext_required = 0
|
||||
endif
|
||||
|
||||
" Whether the @jsx pragma is required.
|
||||
if !exists('g:jsx_pragma_required')
|
||||
let g:jsx_pragma_required = 0
|
||||
endif
|
||||
|
||||
if g:jsx_pragma_required && !exists('b:jsx_ext_found')
|
||||
" Look for the @jsx pragma. It must be included in a docblock comment
|
||||
" before anything else in the file (except whitespace).
|
||||
let b:jsx_pragma_found = search(s:jsx_pragma_pattern, 'npw')
|
||||
endif
|
||||
|
||||
if g:jsx_pragma_required && !b:jsx_pragma_found | return 0 | endif
|
||||
if g:jsx_ext_required && !exists('b:jsx_ext_found') &&
|
||||
\ !(get(g:,'jsx_check_react_import') && search(s:jsx_prevalent_pattern, 'nw'))
|
||||
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
|
||||
augroup end
|
||||
endif
|
||||
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'kotlin') == -1
|
||||
augroup filetypedetect
|
||||
" kotlin, from kotlin.vim in udalov/kotlin-vim
|
||||
@@ -1377,22 +1324,6 @@ au BufRead,BufNewFile *.ax set syntax=tptp
|
||||
augroup end
|
||||
endif
|
||||
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'tsx') == -1
|
||||
augroup filetypedetect
|
||||
" tsx, from typescript.vim in ianks/vim-tsx
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Vim ftdetect file
|
||||
"
|
||||
" Language: TSX (JavaScript)
|
||||
" Maintainer: Ian Ker-Seymer <i.kerseymer@gmail.com>
|
||||
"
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
autocmd BufNewFile,BufRead *.tsx let b:tsx_ext_found = 1
|
||||
autocmd BufNewFile,BufRead *.tsx set filetype=typescript.tsx
|
||||
augroup end
|
||||
endif
|
||||
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'twig') == -1
|
||||
augroup filetypedetect
|
||||
" twig, from twig.vim in lumiliet/vim-twig
|
||||
|
||||
Reference in New Issue
Block a user