Просмотр исходного кода

Allow Plug command even when git executable is not found (#52)

- plug#begin() will return 1 even when git executable is not found
    - Commands that require git will not be available
- If you wish to ignore the error message prepend `silent!` to the call
Junegunn Choi 11 лет назад
Родитель
Сommit
c1bbbaf3ef
1 измененных файлов с 4 добавлено и 5 удалено
  1. 4 5
      plug.vim

+ 4 - 5
plug.vim

@@ -93,10 +93,6 @@ function! plug#begin(...)
     return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.')
     return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.')
   endif
   endif
 
 
-  if !executable('git')
-    return s:err('`git` executable not found. vim-plug requires git.')
-  endif
-
   let g:plug_home = home
   let g:plug_home = home
   let g:plugs = {}
   let g:plugs = {}
   " we want to keep track of the order plugins where registered.
   " we want to keep track of the order plugins where registered.
@@ -107,7 +103,10 @@ function! plug#begin(...)
 endfunction
 endfunction
 
 
 function! s:define_commands()
 function! s:define_commands()
-  command! -nargs=+ -bar Plug   call s:add(<args>)
+  command! -nargs=+ -bar Plug call s:add(<args>)
+  if !executable('git')
+    return s:err('`git` executable not found. vim-plug requires git.')
+  endif
   command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install('<bang>' == '!', <f-args>)
   command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install('<bang>' == '!', <f-args>)
   command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate  call s:update('<bang>' == '!', <f-args>)
   command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate  call s:update('<bang>' == '!', <f-args>)
   command! -nargs=0 -bar -bang PlugClean call s:clean('<bang>' == '!')
   command! -nargs=0 -bar -bang PlugClean call s:clean('<bang>' == '!')