Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't error out early, if git not exists #392

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions plug.vim
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ function! plug#begin(...)
return 1
endfunction

function! s:define_commands()
command! -nargs=+ -bar Plug call s:add(<args>)
function! s:git_exists()
if !executable('git')
return s:err('`git` executable not found. vim-plug requires git.')
endif
endfunction

function! s:define_commands()
command! -nargs=+ -bar Plug call s:add(<args>)
command! -nargs=0 -bar -bang PlugClean call s:clean(<bang>0)
command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install(<bang>0, [<f-args>])
command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update(<bang>0, [<f-args>])
command! -nargs=0 -bar -bang PlugClean call s:clean(<bang>0)
command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:esc(s:me) | endif
command! -nargs=0 -bar PlugStatus call s:status()
command! -nargs=0 -bar PlugDiff call s:diff()
Expand Down Expand Up @@ -776,6 +779,10 @@ function! s:names(...)
endfunction

function! s:update_impl(pull, force, args) abort
if !s:git_exists()
return
endif

let args = copy(a:args)
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
\ remove(args, -1) : get(g:, 'plug_threads', 16)
Expand Down Expand Up @@ -1847,6 +1854,10 @@ function! s:clean(force)
endfunction

function! s:upgrade()
if !s:git_exists()
return
endif

echo 'Downloading the latest version of vim-plug'
redraw
let tmp = tempname()
Expand Down Expand Up @@ -1880,6 +1891,9 @@ function! s:upgrade_specs()
endfunction

function! s:status()
if !s:git_exists()
return
endif
call s:prepare()
call append(0, 'Checking plugins')
call append(1, '')
Expand Down Expand Up @@ -2012,6 +2026,9 @@ function! s:append_ul(lnum, text)
endfunction

function! s:diff()
if !s:git_exists()
return
endif
call s:prepare()
call append(0, ['Collecting changes ...', ''])
let cnts = [0, 0]
Expand Down Expand Up @@ -2071,6 +2088,9 @@ function! s:revert()
endfunction

function! s:snapshot(force, ...) abort
if !s:git_exists()
return
endif
call s:prepare()
setf vim
call append(0, ['" Generated by vim-plug',
Expand Down Expand Up @@ -2117,4 +2137,3 @@ endif

let &cpo = s:cpo_save
unlet s:cpo_save