diff options
Diffstat (limited to 'polyglot.vim')
-rw-r--r-- | polyglot.vim | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/polyglot.vim b/polyglot.vim index 9199a207..3ac6ef38 100644 --- a/polyglot.vim +++ b/polyglot.vim @@ -4,13 +4,6 @@ let s:cpo_save = &cpo set cpo&vim -func! polyglot#ObserveShebang() - augroup polyglot-observer - au! CursorHold,CursorHoldI,BufWritePost <buffer> - \ if polyglot#Shebang() | au! polyglot-observer CursorHold,CursorHoldI,BufWritePost | endif - augroup END -endfunc - func! polyglot#Shebang() if getline(1) =~# "^#!" let ft = polyglot#ShebangFiletype() @@ -84,6 +77,14 @@ if exists('g:polyglot_test') autocmd! endif +func! polyglot#Observe(fn) + let b:polyglot_observe = a:fn + augroup polyglot-observer + au! CursorHold,CursorHoldI,BufWritePost <buffer> + \ execute('if polyglot#' . b:polyglot_observe . '() | au! polyglot-observer | endif') + augroup END +endfunc + let s:disabled_packages = {} let s:new_polyglot_disabled = [] @@ -170,7 +171,7 @@ au! BufNewFile,BufRead,StdinReadPost * if expand("<afile>") !~ g:ft_ignore_pat | \ call polyglot#Shebang() | endif au BufEnter * if &ft == "" && expand("<afile>") !~ g:ft_ignore_pat | - \ call polyglot#ObserveShebang() | endif + \ call polyglot#Observe('Shebang') | endif augroup END |