1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:40:06 +08:00

Fix plugin manager (#1962)

use dein only when has patch 7.4.2071
This commit is contained in:
Wang Shidong 2018-07-21 15:34:13 +08:00 committed by GitHub
parent 0c12b784a0
commit a41d4a0ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 24 deletions

View File

@ -482,9 +482,14 @@ let g:spacevim_simple_mode = 0
" The default file manager of SpaceVim. Default is 'vimfiler'.
let g:spacevim_filemanager = 'vimfiler'
""
" The default plugin manager of SpaceVim. Default is 'dein'.
" The default plugin manager of SpaceVim.
" if has patch 7.4.2071, the default value is dein. Otherwise it is neobundle.
" Options are dein, neobundle, or vim-plug.
let g:spacevim_plugin_manager = 'dein'
if has('patch-7.4.2071')
let g:spacevim_plugin_manager = 'dein'
else
let g:spacevim_plugin_manager = 'neobundle'
endif
""
" @section plugin_manager_processes, options-plugin_manager_processes

View File

@ -63,7 +63,11 @@ endfunction
" @vimlint(EVL103, 1, a:CmdLine)
" @vimlint(EVL103, 1, a:CursorPos)
function! SpaceVim#commands#complete_plugin(ArgLead, CmdLine, CursorPos) abort
return join(keys(dein#get()) + ['SpaceVim'], "\n")
if g:spacevim_plugin_manager ==# 'dein'
return join(keys(dein#get()) + ['SpaceVim'], "\n")
elseif g:spacevim_plugin_manager ==# 'neobundle'
return join(map(neobundle#config#get_neobundles(), 'v:val.name'), "\n")
endif
endfunction
" @vimlint(EVL103, 0, a:ArgLead)
" @vimlint(EVL103, 0, a:CmdLine)
@ -98,6 +102,11 @@ endfunction
function! SpaceVim#commands#update_plugin(...) abort
if g:spacevim_plugin_manager ==# 'neobundle'
if a:0 == 0
call SpaceVim#plugins#manager#update()
else
call SpaceVim#plugins#manager#update(a:000)
endif
elseif g:spacevim_plugin_manager ==# 'dein'
if a:0 == 0
call SpaceVim#plugins#manager#update()
@ -118,11 +127,16 @@ endfunction
function! SpaceVim#commands#install_plugin(...) abort
if g:spacevim_plugin_manager ==# 'neobundle'
if a:0 == 0
call SpaceVim#plugins#manager#install()
else
call SpaceVim#plugins#manager#install(a:000)
endif
elseif g:spacevim_plugin_manager ==# 'dein'
if a:0 == 0
call SpaceVim#plugins#manager#install()
else
call dein#install(a:000)
call SpaceVim#plugins#manager#install(a:000)
endif
elseif g:spacevim_plugin_manager ==# 'vim-plug'
endif

View File

@ -106,14 +106,25 @@ function! s:need_cmd(cmd) abort
endif
endfunction
function! s:get_uninstalled_plugins() abort
return filter(values(dein#get()), '!isdirectory(v:val.path)')
endfunction
if g:spacevim_plugin_manager ==# 'neobundle'
function! s:get_uninstalled_plugins() abort
return filter(neobundle#config#get_neobundles(), '!isdirectory(v:val.path)')
endfunction
elseif g:spacevim_plugin_manager ==# 'dein'
function! s:get_uninstalled_plugins() abort
return filter(values(dein#get()), '!isdirectory(v:val.path)')
endfunction
endif
function! SpaceVim#plugins#manager#reinstall(...) abort
call dein#reinstall(a:1)
endfunction
if g:spacevim_plugin_manager ==# 'neobundle'
function! SpaceVim#plugins#manager#reinstall(...) abort
call neobundle#commands#reinstall(a:1)
endfunction
elseif g:spacevim_plugin_manager ==# 'dein'
function! SpaceVim#plugins#manager#reinstall(...) abort
call dein#reinstall(a:1)
endfunction
endif
" @vimlint(EVL102, 1, l:i)
@ -152,7 +163,11 @@ function! SpaceVim#plugins#manager#install(...) abort
let s:start_time = reltime()
for i in range(g:spacevim_plugin_manager_processes)
if !empty(s:plugins)
let repo = dein#get(s:LIST.shift(s:plugins))
if g:spacevim_plugin_manager ==# 'dein'
let repo = dein#get(s:LIST.shift(s:plugins))
elseif g:spacevim_plugin_manager ==# 'neobundle'
let repo = neobundle#get(s:LIST.shift(s:plugins))
endif
if !empty(repo)
call s:install(repo)
endif
@ -184,7 +199,12 @@ function! SpaceVim#plugins#manager#update(...) abort
if exists('s:recache_done')
unlet s:recache_done
endif
let s:plugins = a:0 == 0 ? sort(keys(dein#get())) : sort(copy(a:1))
if g:spacevim_plugin_manager ==# 'dein'
let s:plugins = a:0 == 0 ? sort(keys(dein#get())) : sort(copy(a:1))
elseif g:spacevim_plugin_manager ==# 'neobundle'
let s:plugins = a:0 == 0 ? sort(map(neobundle#config#get_neobundles(), 'v:val.name')) : sort(copy(a:1))
elseif g:spacevim_plugin_manager ==# 'vim-plug'
endif
if a:0 == 0
call add(s:plugins, 'SpaceVim')
endif
@ -203,8 +223,13 @@ function! SpaceVim#plugins#manager#update(...) abort
let s:start_time = reltime()
for i in range(g:spacevim_plugin_manager_processes)
if !empty(s:plugins)
let reponame = s:LIST.shift(s:plugins)
let repo = dein#get(reponame)
if g:spacevim_plugin_manager ==# 'dein'
let reponame = s:LIST.shift(s:plugins)
let repo = dein#get(reponame)
elseif g:spacevim_plugin_manager ==# 'neobundle'
let reponame = s:LIST.shift(s:plugins)
let repo = neobundle#get(reponame)
endif
if !empty(repo)
call s:pull(repo)
elseif reponame ==# 'SpaceVim'
@ -388,7 +413,7 @@ endfunction
function! s:install(repo) abort
let s:pct += 1
let s:ui_buf[a:repo.name] = s:pct
let url = 'https://github.com/' . a:repo.repo
let url = 'https://github.com/' . (has_key(a:repo, 'repo') ? a:repo.repo : a:repo.orig_path)
let argv = ['git', 'clone', '--recursive', '--progress', url, a:repo.path]
if s:JOB.vim_job || s:JOB.nvim_job
let jobid = s:JOB.start(argv,{
@ -550,12 +575,18 @@ function! s:open_plugin_dir() abort
enew
exe 'resize ' . &lines * 30 / 100
let shell = empty($SHELL) ? SpaceVim#api#import('system').isWindows ? 'cmd.exe' : 'bash' : $SHELL
if g:spacevim_plugin_manager ==# 'dein'
let path = dein#get(keys(plugin)[0]).path
elseif g:spacevim_plugin_manager ==# 'neobundle'
let path = neobundle#get(keys(plugin)[0]).path
elseif g:spacevim_plugin_manager ==# 'vim-plug'
endif
if has('nvim') && exists('*termopen')
call termopen(shell, {'cwd' : dein#get(keys(plugin)[0]).path})
call termopen(shell, {'cwd' : path})
elseif exists('*term_start')
call term_start(shell, {'curwin' : 1, 'term_finish' : 'close', 'cwd' : dein#get(keys(plugin)[0]).path})
call term_start(shell, {'curwin' : 1, 'term_finish' : 'close', 'cwd' : path})
else
exe 'VimShell ' . dein#get(keys(plugin)[0]).path
exe 'VimShell ' . path
endif
endif
endfunction

View File

@ -103,7 +103,13 @@ function! zvim#plug#end() abort
if g:spacevim_plugin_manager ==# 'neobundle'
call neobundle#end()
if g:spacevim_checkinstall == 1
NeoBundleCheck
silent! let g:_spacevim_checking_flag = neobundle#exists_not_installed_bundles()
if g:_spacevim_checking_flag
augroup SpaceVimCheckInstall
au!
au VimEnter * SPInstall
augroup END
endif
endif
elseif g:spacevim_plugin_manager ==# 'dein'
call dein#end()

View File

@ -540,10 +540,6 @@ plugins will be installed.
*g:spacevim_filemanager*
The default file manager of SpaceVim. Default is 'vimfiler'.
*g:spacevim_plugin_manager*
The default plugin manager of SpaceVim. Default is 'dein'. Options are dein,
neobundle, or vim-plug.
*g:spacevim_plugin_manager_processes*
Set the max process of SpaceVim plugin manager

View File

@ -6,4 +6,6 @@
" License: GPLv3
"=============================================================================
" call neobundle#get()
execute 'source' fnamemodify(expand('<sfile>'), ':h').'/config/main.vim'