diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2020-09-24 22:52:50 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-09-24 22:52:50 +0200 |
commit | a6a6aeab76bef135d9f76534efa5ee7391c4ed2a (patch) | |
tree | 5185bc4f10e43058b3565c3eeef827327b26eab4 /autoload/polyglot.vim | |
parent | 444e7f184df91f1605f06242ad68defb33c2f454 (diff) | |
download | vim-polyglot-4.12.0.tar.gz vim-polyglot-4.12.0.zip |
Improve django filetype detection, closes #560v4.12.0
Diffstat (limited to 'autoload/polyglot.vim')
-rw-r--r-- | autoload/polyglot.vim | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/autoload/polyglot.vim b/autoload/polyglot.vim index d0e95b75..b995d228 100644 --- a/autoload/polyglot.vim +++ b/autoload/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() @@ -392,7 +385,8 @@ func! polyglot#DetectHtmlFiletype() set ft=xhtml | return endif endfor - set ft=html | return + set ft=html | au! BufWritePost <buffer> ++once call polyglot#DetectHtmlFiletype() + return endfunc @@ -411,6 +405,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 = [] @@ -497,7 +499,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 |