From 054f1b81d469dc8d153f03b04c2eee0bfc980414 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 13 Jul 2018 11:00:58 +1200 Subject: Rename and refine reload_vimrc_filetype.vim --- vim/plugin/reload.vim | 28 ---------------------------- vim/plugin/reload_vimrc_filetype.vim | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 28 deletions(-) delete mode 100644 vim/plugin/reload.vim create mode 100644 vim/plugin/reload_vimrc_filetype.vim (limited to 'vim') diff --git a/vim/plugin/reload.vim b/vim/plugin/reload.vim deleted file mode 100644 index d1493ad1..00000000 --- a/vim/plugin/reload.vim +++ /dev/null @@ -1,28 +0,0 @@ -" -" reload_vimrc_filetype.vim: Add hook to reload active buffer's filetype when -" vimrc reloaded, so that we don't end up indenting four spaces in an open -" VimL file, etc. Requires Vim 7.1 or 7.0 with patch 187 (SourceCmd event.) -" -" Author: Tom Ryder -" License: Same as Vim itself -" -if exists('g:loaded_reload_vimrc_filetype') || &compatible - finish -endif -if !has('autocmd') || v:version < 700 || v:version == 700 && !has('patch187') - finish -endif -let g:loaded_reload_vimrc_filetype = 1 - -function! s:Reload() - if &filetype !=# '' - doautocmd filetypedetect BufRead - endif - source $MYVIMRC - echomsg 'Reloaded vimrc: '.$MYVIMRC -endfunction - -augroup reload - autocmd SourceCmd $MYVIMRC - \ call s:Reload() -augroup END diff --git a/vim/plugin/reload_vimrc_filetype.vim b/vim/plugin/reload_vimrc_filetype.vim new file mode 100644 index 00000000..d4f853b8 --- /dev/null +++ b/vim/plugin/reload_vimrc_filetype.vim @@ -0,0 +1,23 @@ +" +" reload_vimrc_filetype.vim: Add hook to reload active buffer's filetype when +" vimrc reloaded, so that we don't end up indenting four spaces in an open +" VimL file, etc. Requires Vim 7.1 or 7.0 with patch 187 (SourceCmd event.) +" +" Author: Tom Ryder +" License: Same as Vim itself +" +if exists('g:loaded_reload_vimrc_filetype') || &compatible + finish +endif +if !has('autocmd') || v:version < 700 || v:version == 700 && !has('patch187') + finish +endif +let g:loaded_reload_vimrc_filetype = 1 + +" This SourceCmd intercepts :source for .vimrc +augroup reload_vimrc_filetype + autocmd SourceCmd $MYVIMRC + \ source + \|doautocmd filetypedetect BufRead + \|echomsg 'Reloaded vimrc: '.expand('') +augroup END -- cgit v1.2.3