mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 05:20:04 +08:00
Add resume feature of plugin manager
This commit is contained in:
parent
a3edb4119a
commit
e8a5f028d2
@ -21,6 +21,7 @@ let s:pulling_repos = {}
|
|||||||
" key : plugin name, value : buf line number in manager buffer.
|
" key : plugin name, value : buf line number in manager buffer.
|
||||||
let s:ui_buf = {}
|
let s:ui_buf = {}
|
||||||
let s:plugin_manager_buffer = 0
|
let s:plugin_manager_buffer = 0
|
||||||
|
let s:plugin_manager_buffer_lines = []
|
||||||
|
|
||||||
" install plugin manager
|
" install plugin manager
|
||||||
function! s:install_manager() abort
|
function! s:install_manager() abort
|
||||||
@ -114,15 +115,20 @@ endfunction
|
|||||||
" @vimlint(EVL102, 1, l:i)
|
" @vimlint(EVL102, 1, l:i)
|
||||||
function! SpaceVim#plugins#manager#install(...) abort
|
function! SpaceVim#plugins#manager#install(...) abort
|
||||||
let s:plugins = a:0 == 0 ? sort(map(s:get_uninstalled_plugins(), 'v:val.name')) : sort(copy(a:1))
|
let s:plugins = a:0 == 0 ? sort(map(s:get_uninstalled_plugins(), 'v:val.name')) : sort(copy(a:1))
|
||||||
if !s:new_window() || empty(s:plugins)
|
if s:new_window() == 0
|
||||||
echohl WarningMsg
|
echohl WarningMsg
|
||||||
echom '[SpaceVim] [plugin manager] plugin manager process is not finished.'
|
echom '[SpaceVim] [plugin manager] plugin manager process is not finished.'
|
||||||
echohl None
|
echohl None
|
||||||
return
|
return
|
||||||
|
elseif s:new_window() == 1
|
||||||
|
" resume window
|
||||||
|
return
|
||||||
|
elseif empty(s:plugins)
|
||||||
|
echohl WarningMsg
|
||||||
|
echom '[SpaceVim] Wrong plugin name, or all of the plugins are already installed.'
|
||||||
|
echohl None
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nomodifiable nospell
|
|
||||||
setf SpaceVimPlugManager
|
|
||||||
nnoremap <silent> <buffer> q :bd<CR>
|
|
||||||
let s:pct = 0
|
let s:pct = 0
|
||||||
let s:total = len(s:plugins)
|
let s:total = len(s:plugins)
|
||||||
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Installing plugins (' . s:pct . '/' . s:total . ')')
|
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Installing plugins (' . s:pct . '/' . s:total . ')')
|
||||||
@ -150,15 +156,14 @@ endfunction
|
|||||||
|
|
||||||
" @vimlint(EVL102, 1, l:i)
|
" @vimlint(EVL102, 1, l:i)
|
||||||
function! SpaceVim#plugins#manager#update(...) abort
|
function! SpaceVim#plugins#manager#update(...) abort
|
||||||
if !s:new_window()
|
if s:new_window() == 0
|
||||||
echohl WarningMsg
|
echohl WarningMsg
|
||||||
echom '[SpaceVim] [plugin manager] plugin updating is not finished.'
|
echom '[SpaceVim] [plugin manager] plugin updating is not finished.'
|
||||||
echohl None
|
echohl None
|
||||||
return
|
return
|
||||||
|
elseif s:new_window() == 1
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nomodifiable nospell
|
|
||||||
setf SpaceVimPlugManager
|
|
||||||
nnoremap <silent> <buffer> q :bd<CR>
|
|
||||||
let s:pct = 0
|
let s:pct = 0
|
||||||
let s:plugins = a:0 == 0 ? sort(keys(dein#get())) : sort(copy(a:1))
|
let s:plugins = a:0 == 0 ? sort(keys(dein#get())) : sort(copy(a:1))
|
||||||
let s:total = len(s:plugins)
|
let s:total = len(s:plugins)
|
||||||
@ -333,19 +338,45 @@ endfunction
|
|||||||
|
|
||||||
function! s:new_window() abort
|
function! s:new_window() abort
|
||||||
if s:plugin_manager_buffer != 0 && bufexists(s:plugin_manager_buffer)
|
if s:plugin_manager_buffer != 0 && bufexists(s:plugin_manager_buffer)
|
||||||
|
" buffer exist, process has not finished!
|
||||||
return 0
|
return 0
|
||||||
|
elseif s:plugin_manager_buffer != 0 && !bufexists(s:plugin_manager_buffer)
|
||||||
|
" buffer is hidden, process has not finished!
|
||||||
|
call s:resume_window()
|
||||||
|
return 1
|
||||||
else
|
else
|
||||||
execute get(g:, 'spacevim_window', 'vertical topleft new')
|
execute get(g:, 'spacevim_window', 'vertical topleft new')
|
||||||
let s:plugin_manager_buffer = bufnr('%')
|
let s:plugin_manager_buffer = bufnr('%')
|
||||||
return 1
|
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nomodifiable nospell
|
||||||
|
setf SpaceVimPlugManager
|
||||||
|
nnoremap <silent> <buffer> q :bd<CR>
|
||||||
|
" process has finished or does not start.
|
||||||
|
return 2
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:resume_window() abort
|
||||||
|
execute get(g:, 'spacevim_window', 'vertical topleft new')
|
||||||
|
let s:plugin_manager_buffer = bufnr('%')
|
||||||
|
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell
|
||||||
|
setf SpaceVimPlugManager
|
||||||
|
nnoremap <silent> <buffer> q :bd<CR>
|
||||||
|
call setline(1, s:plugin_manager_buffer_lines)
|
||||||
|
setlocal nomodifiable
|
||||||
|
endfunction
|
||||||
|
|
||||||
" change modifiable before setline
|
" change modifiable before setline
|
||||||
if has('nvim') && exists('*nvim_buf_set_lines')
|
if has('nvim') && exists('*nvim_buf_set_lines')
|
||||||
function! s:set_buf_line(bufnr, nr, line) abort
|
function! s:set_buf_line(bufnr, nr, line) abort
|
||||||
call setbufvar(s:plugin_manager_buffer,'&ma', 1)
|
call setbufvar(s:plugin_manager_buffer,'&ma', 1)
|
||||||
call nvim_buf_set_lines(a:bufnr, a:nr - 1, a:nr, 0, [a:line])
|
if bufexists(s:plugin_manager_buffer)
|
||||||
|
call nvim_buf_set_lines(a:bufnr, a:nr - 1, a:nr, 0, [a:line])
|
||||||
|
endif
|
||||||
|
if len(s:plugin_manager_buffer_lines) >= a:nr
|
||||||
|
let s:plugin_manager_buffer_lines[a:nr - 1] = a:line
|
||||||
|
else
|
||||||
|
call add(s:plugin_manager_buffer_lines, a:line)
|
||||||
|
endif
|
||||||
call setbufvar(s:plugin_manager_buffer,'&ma', 0)
|
call setbufvar(s:plugin_manager_buffer,'&ma', 0)
|
||||||
endfunction
|
endfunction
|
||||||
elseif has('python')
|
elseif has('python')
|
||||||
@ -356,19 +387,25 @@ elseif has('python')
|
|||||||
" @vimlint(EVL103, 1, a:line)
|
" @vimlint(EVL103, 1, a:line)
|
||||||
function! s:set_buf_line(bufnr, nr, line) abort
|
function! s:set_buf_line(bufnr, nr, line) abort
|
||||||
call setbufvar(s:plugin_manager_buffer,'&ma', 1)
|
call setbufvar(s:plugin_manager_buffer,'&ma', 1)
|
||||||
py bufnr = string.atoi(vim.eval("a:bufnr"))
|
if bufexists(s:plugin_manager_buffer)
|
||||||
py linr = string.atoi(vim.eval("a:nr")) - 1
|
py bufnr = string.atoi(vim.eval("a:bufnr"))
|
||||||
py str = vim.eval("a:line")
|
py linr = string.atoi(vim.eval("a:nr")) - 1
|
||||||
py vim.buffers[bufnr][linr] = str
|
py str = vim.eval("a:line")
|
||||||
|
py vim.buffers[bufnr][linr] = str
|
||||||
|
endif
|
||||||
|
let s:plugin_manager_buffer_lines[a:nr - 1] = a:line
|
||||||
call setbufvar(s:plugin_manager_buffer,'&ma', 0)
|
call setbufvar(s:plugin_manager_buffer,'&ma', 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:append_buf_line(bufnr, nr, line) abort
|
function! s:append_buf_line(bufnr, nr, line) abort
|
||||||
call setbufvar(s:plugin_manager_buffer,'&ma', 1)
|
call setbufvar(s:plugin_manager_buffer,'&ma', 1)
|
||||||
py bufnr = string.atoi(vim.eval("a:bufnr"))
|
if bufexists(s:plugin_manager_buffer)
|
||||||
py linr = string.atoi(vim.eval("a:nr")) - 1
|
py bufnr = string.atoi(vim.eval("a:bufnr"))
|
||||||
py str = vim.eval("a:line")
|
py linr = string.atoi(vim.eval("a:nr")) - 1
|
||||||
py vim.buffers[bufnr].append(str)
|
py str = vim.eval("a:line")
|
||||||
|
py vim.buffers[bufnr].append(str)
|
||||||
|
endif
|
||||||
|
call add(s:plugin_manager_buffer_lines, a:line)
|
||||||
call setbufvar(s:plugin_manager_buffer,'&ma', 0)
|
call setbufvar(s:plugin_manager_buffer,'&ma', 0)
|
||||||
endfunction
|
endfunction
|
||||||
" @vimlint(EVL103, 0, a:bufnr)
|
" @vimlint(EVL103, 0, a:bufnr)
|
||||||
@ -384,8 +421,15 @@ else
|
|||||||
endfunction
|
endfunction
|
||||||
function! s:set_buf_line(bufnr, nr, line) abort
|
function! s:set_buf_line(bufnr, nr, line) abort
|
||||||
call setbufvar(a:bufnr,'&ma', 1)
|
call setbufvar(a:bufnr,'&ma', 1)
|
||||||
if s:focus_main_win() >= 0
|
if bufexists(s:plugin_manager_buffer)
|
||||||
call setline(a:nr, a:line)
|
if s:focus_main_win() >= 0
|
||||||
|
call setline(a:nr, a:line)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if len(s:plugin_manager_buffer_lines) >= a:nr
|
||||||
|
let s:plugin_manager_buffer_lines[a:nr - 1] = a:line
|
||||||
|
else
|
||||||
|
call add(s:plugin_manager_buffer_lines, a:line)
|
||||||
endif
|
endif
|
||||||
call setbufvar(a:bufnr,'&ma', 0)
|
call setbufvar(a:bufnr,'&ma', 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user