From 9ff714cb6c43b920fd76ff793641c5191bf2e991 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 24 Sep 2020 18:52:58 +0200 Subject: Extract non-generated code to polyglot.vim --- ftdetect/polyglot.vim | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) (limited to 'ftdetect') diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index d6379ae2..cba8cf86 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1,3 +1,5 @@ +""" ftdetect/polyglot.vim + " don't spam the user when Vim is started in Vi compatibility mode let s:cpo_save = &cpo set cpo&vim @@ -87,9 +89,6 @@ endfunc augroup filetypedetect -au! filetypedetect BufRead,BufNewFile,StdinReadPost * - -" filetypes if !has_key(s:disabled_packages, '8th') au! BufRead,BufNewFile *.8th @@ -2017,20 +2016,12 @@ if !has_key(s:disabled_packages, 'tads') endif -" end filetypes -func! s:PolyglotFallback() - if expand("") !~ g:ft_ignore_pat - if getline(1) =~# "^#!" - call polyglot#Shebang() - endif - if &filetype == '' - runtime! scripts.vim - endif - endif -endfunc +au! BufNewFile,BufRead,StdinReadPost * if expand("") !~ g:ft_ignore_pat | + \ call polyglot#Shebang() | endif -au BufNewFile,BufRead,StdinReadPost * call s:PolyglotFallback() +au BufEnter * if &ft == "" && expand("") !~ g:ft_ignore_pat | + \ call polyglot#ObserveShebang() | endif augroup END @@ -2227,17 +2218,6 @@ endfunc au VimEnter * call s:verify() -func! s:observe_filetype() - augroup polyglot-observer - au! CursorHold,CursorHoldI - \ if polyglot#Shebang() | au! polyglot-observer CursorHold,CursorHoldI | endif - augroup END -endfunc - -au BufEnter * if &ft == "" && expand("") !~ g:ft_ignore_pat - \ | call s:observe_filetype() | endif - - " Save polyglot_disabled without postfixes if exists('g:polyglot_disabled') let g:polyglot_disabled = s:new_polyglot_disabled @@ -2245,4 +2225,3 @@ endif " restore Vi compatibility settings let &cpo = s:cpo_save -unlet s:cpo_save -- cgit v1.2.3