aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-13 10:41:45 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-13 10:41:45 +1200
commit4e44ad60ad22cef98e6b51bb43bf67c34343ac08 (patch)
treeadbbf932f0426ebed505fca9dd4c926405742071 /vim/plugin
parentAdd missing angle bracket for Vim ftplugin undo (diff)
downloaddotfiles-4e44ad60ad22cef98e6b51bb43bf67c34343ac08.tar.gz
dotfiles-4e44ad60ad22cef98e6b51bb43bf67c34343ac08.zip
Move .vimrc reloading stuff into custom plugin
Not sure whether I'll bother packaging this one.
Diffstat (limited to 'vim/plugin')
-rw-r--r--vim/plugin/reload.vim28
1 files changed, 28 insertions, 0 deletions
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 <tom@sanctum.geek.nz>
+" 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