From 4e44ad60ad22cef98e6b51bb43bf67c34343ac08 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 13 Jul 2018 10:41:45 +1200 Subject: Move .vimrc reloading stuff into custom plugin Not sure whether I'll bother packaging this one. --- vim/plugin/reload.vim | 28 ++++++++++++++++++++++++++++ vim/vimrc | 12 ------------ 2 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 vim/plugin/reload.vim (limited to 'vim') diff --git a/vim/plugin/reload.vim b/vim/plugin/reload.vim new file mode 100644 index 00000000..d1493ad1 --- /dev/null +++ b/vim/plugin/reload.vim @@ -0,0 +1,28 @@ +" +" 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/vimrc b/vim/vimrc index 92052ece..fbe0f177 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -287,15 +287,3 @@ nnoremap :enew " Source any .vim files from ~/.vim/config runtime! config/*.vim - -" If we reloaded, reload filetype detection for the active buffer too, so that -" any local settings for it are restored -if exists('g:loaded_vimrc') - if &filetype !=# '' - doautocmd filetypedetect BufRead - endif - echomsg 'Reloaded vimrc: '.$MYVIMRC -endif -if 1 - let g:loaded_vimrc = 1 -endif -- cgit v1.2.3