dgy
/
hexagons
Archived
1
0
Fork 0
This repository has been archived on 2021-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
hexagons/.config/nvim/ftdetect/jsx.vim

32 lines
570 B
VimL

function! s:ScanFile()
let n = 1
let nmax = line('$')
if line('$') > 500
let nmax = 500
endif
while n < nmax
if getline(n) =~# "\\v<React>"
return 1
break
endif
let n = n + 1
endwhile
return 0
endfunction
function! s:DetectJSX()
if match(&filetype, '\v<jsx>') != -1
return
endif
if s:ScanFile()
call s:SetJSX()
endif
endfunction
function! s:SetJSX()
noautocmd set filetype+=.jsx
endfunction
autocmd BufNewFile,BufRead *.js.jsx,*.jsx call s:SetJSX()
autocmd BufNewFile,BufRead *.html,*.js call s:DetectJSX()