aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin/reload.vim
blob: d1493ad1d3fe54a519279e696d2ca49868029250 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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