You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
VimL
38 lines
1.2 KiB
VimL
9 years ago
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||
|
" Vim ftdetect file
|
||
|
"
|
||
|
" Language: JSX (JavaScript)
|
||
|
" Maintainer: Max Wang <mxawng@gmail.com>
|
||
|
"
|
||
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||
|
|
||
9 years ago
|
" Whether the .jsx extension is required.
|
||
|
if !exists('g:jsx_ext_required')
|
||
|
let g:jsx_ext_required = 1
|
||
|
endif
|
||
9 years ago
|
|
||
9 years ago
|
" Whether the @jsx pragma is required.
|
||
|
if !exists('g:jsx_pragma_required')
|
||
|
let g:jsx_pragma_required = 0
|
||
|
endif
|
||
|
|
||
8 years ago
|
let s:jsx_pragma_pattern = '\%^\_s*\/\*\*\%(\_.\%(\*\/\)\@!\)*@jsx\_.\{-}\*\/'
|
||
9 years ago
|
|
||
|
" Whether to set the JSX filetype on *.js files.
|
||
9 years ago
|
fu! <SID>EnableJSX()
|
||
8 years ago
|
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
|
||
|
|
||
9 years ago
|
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
|