diff options
Diffstat (limited to '')
-rw-r--r-- | ftdetect/polyglot.vim | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index bec614ae..3dc8a3ec 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -905,7 +905,7 @@ endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ocaml') == -1 augroup filetypedetect " ocaml, from opam.vim in rgrinberg/vim-ocaml -au BufNewFile,BufRead opam,*.opam set filetype=opam +au BufNewFile,BufRead opam,*.opam,*.opam.template set filetype=opam augroup end endif @@ -1105,7 +1105,24 @@ endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'racket') == -1 augroup filetypedetect " racket, from racket.vim in wlangstroth/vim-racket -au BufRead,BufNewFile *.rkt,*.rktl set filetype=racket +" +let g:racket_hash_lang_regexp = '^#lang\s\+\([^][)(}{[:space:]]\+\)' + +" Tries to detect filetype from #lang line; defaults to ft=racket. +function RacketDetectHashLang() + let old_ft = &filetype + + let matches = matchlist(getline(1), g:racket_hash_lang_regexp) + if ! empty(matches) + let &l:filetype = matches[1] + endif + + if &filetype == old_ft + set filetype=racket + endif +endfunction + +au BufRead,BufNewFile *.rkt,*.rktl call RacketDetectHashLang() augroup end endif @@ -1437,15 +1454,15 @@ endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1 augroup filetypedetect - " typescript, from tsx.vim in HerringtonDarkholme/yats.vim -autocmd BufNewFile,BufRead *.tsx setlocal filetype=typescript.tsx + " typescript, from typescript.vim in HerringtonDarkholme/yats.vim +autocmd BufNewFile,BufRead *.ts setlocal filetype=typescript augroup end endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1 augroup filetypedetect - " typescript, from typescript.vim in HerringtonDarkholme/yats.vim -autocmd BufNewFile,BufRead *.ts setlocal filetype=typescript + " typescript, from typescriptreact.vim in HerringtonDarkholme/yats.vim +autocmd BufNewFile,BufRead *.tsx setlocal filetype=typescriptreact augroup end endif |