1 " Vim script
 2 " Last Change: July 23, 2010
 3 " Author: Peter Odding
 4 " URL: http://peterodding.com/code/vim/reload/
 5 " License: MIT
 6 " Version: 0.5.1
 7 
 8 " Support for automatic update using the GLVS plug-in.
 9 " GetLatestVimScripts: 3148 1 :AutoInstall: reload.zip
10 
11 if !exists('g:reload_on_write')
12   let g:reload_on_write = 1
13 endif
14 
15 command! -bar -nargs=? -complete=file ReloadScript call s:ReloadCmd(<q-args>)
16 
17 augroup PluginReloadScripts
18   autocmd!
19   autocmd BufWritePost *.vim nested call s:AutoReload()
20   " The nested keyword is so that SwapExists isn't ignored!
21   autocmd SwapExists * call xolox#reload#open_readonly()
22   autocmd TabEnter * call xolox#reload#windows()
23 augroup END
24 
25 function! s:ReloadCmd(arg)
26   if a:arg !~ '\S'
27     call xolox#reload#script(expand('%:p'))
28   else
29     call xolox#reload#script(fnamemodify(a:arg, ':p'))
30   endif
31 endfunction
32 
33 if !exists('s:auto_reload_active')
34   function! s:AutoReload()
35     if g:reload_on_write
36       let s:auto_reload_active = 1
37       call xolox#reload#script(expand('%:p'))
38       unlet s:auto_reload_active
39     endif
40   endfunction
41 endif
42 
43 " vim: ts=2 sw=2 et