summaryrefslogtreecommitdiffstats
path: root/ftdetect/polyglot.vim
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2020-09-10 15:40:27 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2020-09-10 15:40:27 +0200
commit9243367ba376050621e4c05e8f0439742c1f0f82 (patch)
treeda72230c3a5258fe2be8c90ef0301ac1edd7d547 /ftdetect/polyglot.vim
parent1eed30b2af57538496943da09e298a6facc33002 (diff)
downloadvim-polyglot-4.10.0.tar.gz
vim-polyglot-4.10.0.zip
Automatically detect script filetype when typingv4.10.0
Diffstat (limited to 'ftdetect/polyglot.vim')
-rw-r--r--ftdetect/polyglot.vim23
1 files changed, 16 insertions, 7 deletions
diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim
index 5a95caa1..0fa71e9c 100644
--- a/ftdetect/polyglot.vim
+++ b/ftdetect/polyglot.vim
@@ -1911,12 +1911,11 @@ endif
" end filetypes
-augroup END
-
au BufNewFile,BufRead,StdinReadPost *
\ if !did_filetype() && expand("<afile>") !~ g:ft_ignore_pat
\ | call polyglot#Heuristics() | endif
+augroup END
if !has_key(s:disabled_packages, 'autoindent')
" Code below re-implements sleuth for vim-polyglot
@@ -2088,10 +2087,10 @@ if !has_key(s:disabled_packages, 'autoindent')
endif
endfunction
- augroup polyglot
- autocmd!
- autocmd FileType * call s:detect_indent()
- autocmd User Flags call Hoist('buffer', 5, 'SleuthIndicator')
+ augroup polyglot-sleuth
+ au!
+ au FileType * call s:detect_indent()
+ au User Flags call Hoist('buffer', 5, 'SleuthIndicator')
augroup END
command! -bar -bang Sleuth call s:detect_indent()
@@ -2109,7 +2108,17 @@ func! s:verify()
endif
endfunc
-autocmd VimEnter * call s:verify()
+au VimEnter * call s:verify()
+
+func! s:observe_filetype()
+ augroup polyglot-observer
+ au! CursorHold,CursorHoldI <buffer>
+ \ if polyglot#Heuristics() | au! polyglot-observer CursorHold,CursorHoldI | endif
+ augroup END
+endfunc
+
+au BufEnter * if &ft == "" && expand("<afile>") !~ g:ft_ignore_pat
+ \ | call s:observe_filetype() | endif
" restore Vi compatibility settings
let &cpo = s:cpo_save