1
0
mirror of https://github.com/amix/vimrc synced 2025-07-08 01:25:00 +08:00

add vim-jsx, vim-javascript

This commit is contained in:
Chris Hu
2016-08-18 08:41:38 +08:00
committed by Huaishun Hu
parent 35f23c0128
commit db2bf731a3
15 changed files with 1209 additions and 0 deletions

View File

@ -0,0 +1,36 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim ftdetect file
"
" Language: JSX (JavaScript)
" Maintainer: Max Wang <mxawng@gmail.com>
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Whether the .jsx extension is required.
if !exists('g:jsx_ext_required')
let g:jsx_ext_required = 1
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
" 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
" Whether to set the JSX filetype on *.js files.
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