mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 02:30:03 +08:00
Merge branch 'plugin_opt' into dev
This commit is contained in:
commit
1f6f036282
@ -27,7 +27,6 @@ function! s:warp(argv, opts) abort
|
||||
let obj = {}
|
||||
let obj._argv = a:argv
|
||||
let obj._opts = a:opts
|
||||
|
||||
" @vimlint(EVL103, 1, a:job_id)
|
||||
function! obj._out_cb(job_id, data) abort
|
||||
if has_key(self._opts, 'on_stdout')
|
||||
@ -57,7 +56,9 @@ function! s:warp(argv, opts) abort
|
||||
\ 'exit_cb': obj._exit_cb,
|
||||
\ }
|
||||
\ }
|
||||
|
||||
if has_key(a:opts, 'cwd')
|
||||
call extend(obj.opts, {'cwd' : a:opts.cwd})
|
||||
endif
|
||||
return obj
|
||||
endfunction
|
||||
|
||||
@ -81,7 +82,17 @@ function! s:start(argv, ...) abort
|
||||
let id = len(s:jobs) + 1
|
||||
let opts.jobpid = id
|
||||
let wrapped = s:warp(a:argv, opts)
|
||||
if has_key(wrapped.opts, 'cwd')
|
||||
let old_wd = getcwd()
|
||||
let cwd = expand(wrapped.opts.cwd, 1)
|
||||
" Avoid error E475: Invalid argument: cwd
|
||||
call remove(wrapped.opts, 'cwd')
|
||||
exe 'cd' fnameescape(cwd)
|
||||
endif
|
||||
let job = job_start(wrapped.argv, wrapped.opts)
|
||||
if exists('old_wd')
|
||||
exe 'cd' fnameescape(old_wd)
|
||||
endif
|
||||
call extend(s:jobs, {id : job})
|
||||
return id
|
||||
else
|
||||
|
@ -18,6 +18,7 @@ let s:LIST = SpaceVim#api#import('data#list')
|
||||
" init values
|
||||
let s:plugins = []
|
||||
let s:pulling_repos = {}
|
||||
let s:building_repos = {}
|
||||
" key : plugin name, value : buf line number in manager buffer.
|
||||
let s:ui_buf = {}
|
||||
let s:plugin_manager_buffer = 0
|
||||
@ -261,6 +262,23 @@ function! s:lock_revision(repo) abort
|
||||
call s:VIM_CO.system(cmd)
|
||||
endfunction
|
||||
|
||||
function! s:on_build_exit(id, data, event) abort
|
||||
if a:data == 0 && a:event ==# 'exit'
|
||||
call s:msg_on_build_done(s:building_repos[a:id].name)
|
||||
else
|
||||
call s:msg_on_build_failed(s:building_repos[a:id].name)
|
||||
endif
|
||||
if empty(s:pulling_repos) && empty(s:building_repos)
|
||||
" TODO add elapsed time info.
|
||||
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Installed. Elapsed time: '
|
||||
\ . split(reltimestr(reltime(s:start_time)))[0] . ' sec.')
|
||||
let s:plugin_manager_buffer = 0
|
||||
if g:spacevim_plugin_manager ==# 'dein'
|
||||
call dein#recache_runtimepath()
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" here if a:data == 0, git pull succeed
|
||||
function! s:on_install_exit(id, data, event) abort
|
||||
if a:data == 0 && a:event ==# 'exit'
|
||||
@ -273,11 +291,14 @@ function! s:on_install_exit(id, data, event) abort
|
||||
if get(s:pulling_repos[a:id], 'rev', '') !=# ''
|
||||
call s:lock_revision(s:pulling_repos[a:id])
|
||||
endif
|
||||
if get(s:pulling_repos[a:id], 'build', '') !=# ''
|
||||
call s:build(s:pulling_repos[a:id])
|
||||
endif
|
||||
call remove(s:pulling_repos, string(a:id))
|
||||
if !empty(s:plugins)
|
||||
call s:install(dein#get(s:LIST.shift(s:plugins)))
|
||||
endif
|
||||
if empty(s:pulling_repos)
|
||||
if empty(s:pulling_repos) && empty(s:building_repos)
|
||||
" TODO add elapsed time info.
|
||||
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Installed. Elapsed time: '
|
||||
\ . split(reltimestr(reltime(s:start_time)))[0] . ' sec.')
|
||||
@ -316,6 +337,27 @@ function! s:install(repo) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:build(repo) abort
|
||||
let argv = type(a:repo.build) != 4 ? a:repo.build : s:get_build_argv(a:repo.build)
|
||||
let jobid = s:JOB.start(argv,{
|
||||
\ 'on_exit' : function('s:on_build_exit'),
|
||||
\ 'cwd' : a:repo.path,
|
||||
\ })
|
||||
if jobid != 0
|
||||
let s:building_repos[jobid] = a:repo
|
||||
call s:msg_on_build_start(a:repo.name)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:msg_on_build_start(name) abort
|
||||
call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3,
|
||||
\ '- ' . a:name . ': Building ')
|
||||
endfunction
|
||||
|
||||
function! s:get_build_argv(build) abort
|
||||
" TODO check os
|
||||
return a:build
|
||||
endfunction
|
||||
" + foo.vim: Updating...
|
||||
if has('nvim')
|
||||
function! s:msg_on_start(name) abort
|
||||
@ -365,6 +407,16 @@ function! s:msg_on_install_failed(name) abort
|
||||
call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3, '- ' . a:name . ': Installing failed.')
|
||||
endfunction
|
||||
|
||||
" - foo.vim: Updating done.
|
||||
function! s:msg_on_build_done(name) abort
|
||||
call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3, '- ' . a:name . ': Building done.')
|
||||
endfunction
|
||||
|
||||
" - foo.vim: Updating failed.
|
||||
function! s:msg_on_build_failed(name) abort
|
||||
call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3, '- ' . a:name . ': Building failed.')
|
||||
endfunction
|
||||
|
||||
function! s:new_window() abort
|
||||
if s:plugin_manager_buffer != 0 && bufexists(s:plugin_manager_buffer)
|
||||
" buffer exist, process has not finished!
|
||||
|
Loading…
Reference in New Issue
Block a user