Move vundle install to func, switch to begin/end vundle interface

Sun, 21 May 2017 23:28:19 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 21 May 2017 23:28:19 -0400
changeset 574
3874b97048b0
parent 573
f7755d123d04
child 575
fa876d0471c4

Move vundle install to func, switch to begin/end vundle interface

.vim/autoload/vimrc.vim file | annotate | diff | comparison | revisions
.vimrc file | annotate | diff | comparison | revisions
--- a/.vim/autoload/vimrc.vim
+++ b/.vim/autoload/vimrc.vim
@@ -19,3 +19,29 @@ function! vimrc#MkNonExDir(file, buf) ab
   endif
 endfunction
 
+function! vimrc#VundleInstall() abort
+  " on windows and not cygwin
+  let l:on_windows = (has('win32') || has('win64'))
+
+  let l:vundle_readme = expand(l:on_windows
+    \ ? '~/vimfiles/bundle/vundle/README.md'
+    \ : '~/.vim/bundle/vundle/README.md')
+
+  if !filereadable(l:vundle_readme)
+    if !executable('git')
+      echo "Can't autoinstall Vundle without git"
+      return
+    endif
+
+    if l:on_windows == 0
+      silent !mkdir -p ~/.vim/bundle
+      silent !git clone --depth 1 https://github.com/gmarik/vundle ~/.vim/bundle/vundle
+    else
+      silent execute '!mkdir "'. $HOME .'\vimfiles\bundle"'
+      silent execute '!git clone --depth 1 https://github.com/gmarik/vundle "'. $HOME .'\vimfiles\bundle\vundle"'
+    endif
+
+    echo "Installed Vundle, run :PluginInstall if desired"
+  endif
+
+endfunction
--- a/.vimrc
+++ b/.vimrc
@@ -8,35 +8,14 @@ let s:on_windows=(has('win32') || has('w
 let s:filename=expand('<sfile>')
 
 " Set up Vundle and plugins  {{{
-  let s:installed_vundle=0
-
-  let s:vundle_readme=expand(s:on_windows
-    \ ? '~/vimfiles/bundle/vundle/README.md'
-    \ : '~/.vim/bundle/vundle/README.md')
-
-  if !filereadable(s:vundle_readme)
-    if !executable('git')
-      echo "You probably want git installed and in PATH."
-      quit
-    endif
-
-    echo "Installing Vundle and Plugins...\n"
-    if s:on_windows == 0
-      silent !mkdir -p ~/.vim/bundle
-      silent !git clone --depth 1 https://github.com/gmarik/vundle ~/.vim/bundle/vundle
-    else
-      silent execute '!mkdir "'. $HOME .'\vimfiles\bundle"'
-      silent execute '!git clone --depth 1 https://github.com/gmarik/vundle "'. $HOME .'\vimfiles\bundle\vundle"'
-    endif
-    let s:installed_vundle=1
-  endif
+  call vimrc#VundleInstall()
 
   if s:on_windows == 0
     set rtp+=~/.vim/bundle/vundle/
-    call vundle#rc()
+    call vundle#begin()
   else
     set rtp+=~/vimfiles/bundle/vundle/
-    call vundle#rc('~/vimfiles/bundle')
+    call vundle#begin('~/vimfiles/bundle')
   endif
 
   Plugin 'gmarik/vundle'
@@ -84,15 +63,11 @@ let s:filename=expand('<sfile>')
   catch
   endtry
 
-  if s:installed_vundle == 1
-    echo "Installing Plugins, please ignore key map error messages\n"
-    :PluginInstall
-  endif
+  call vundle#end()
 " }}}
 
 
 " Key maps {{{
-
 nmap <silent> <F1> :Unite buffer<CR>
 nmap <silent> <C-F1> :Unite -quick-match -short-source-names window tab:no-current<CR>
 nmap <silent> <A-F1> :Unite session<CR>

mercurial