aboutsummaryrefslogtreecommitdiff
path: root/vim/filetype.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-08 17:24:41 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-08 17:24:41 +1200
commitcbb65c137e969cae4d442411c6796a6027316a2e (patch)
treee380d0125a23ea905652c37ca335317997b28529 /vim/filetype.vim
parenteb3869b1e1f884da397fbe39716ed5448cf3f97e (diff)
downloaddotfiles-cbb65c137e969cae4d442411c6796a6027316a2e.tar.gz
dotfiles-cbb65c137e969cae4d442411c6796a6027316a2e.zip
Move shebang updating into filetype.vim
Much more logical location.
Diffstat (limited to 'vim/filetype.vim')
-rw-r--r--vim/filetype.vim13
1 files changed, 13 insertions, 0 deletions
diff --git a/vim/filetype.vim b/vim/filetype.vim
index ad2545a0..bda01984 100644
--- a/vim/filetype.vim
+++ b/vim/filetype.vim
@@ -42,6 +42,13 @@ function! s:StripRepeat()
endfunction
+" Check if the first line is a shebang
+function! s:CheckShebang()
+ if line('''[') == 1 && stridx(getline(1), '#!') == 0
+ doautocmd filetypedetect BufRead
+ endif
+endfunction
+
" Use our own filetype detection rules
augroup filetypedetect
autocmd!
@@ -508,4 +515,10 @@ augroup filetypedetect
\| runtime scripts.vim
\|endif
+ " If supported, on leaving insert mode, check whether the first line was "
+ " changed and is a shebang format, and if so, re-run filetype detection
+ if v:version > 700
+ autocmd InsertLeave * call s:CheckShebang()
+ endif
+
augroup END