k-takata / minpac

A minimal package manager for Vim 8+ (and Neovim)
839 stars 30 forks source link

Echo status to stdout #83

Closed netmute closed 5 years ago

netmute commented 5 years ago

I update my vim plugins from a shell script (vim +PackUpdate). Is there a way I can print the results of the update to stdout?

hayatogh commented 5 years ago

I have also similar ex-command to update. I think you can use :redir and :print in -s-ex mode. Add function and command like this in your vimrc,

function! s:PrintPackUpdateFunc()
        redir @a
        PackUpdate
        redir END
        new
        put a
        %print
        qa!
endfunction
command! PPU call <SID>PrintPackUpdateFunc()

and call it. vim -ENs -u $HOME/.vimrc "+set nonumber nolist" +PPU I set number and list in my vimrc and I add nonumber and nolist to disable it.


FYI, minpac has a synchronization bug. If you automate like above, vim quits before all update jobs done. When you run 8 jobs to update, vim quits just after it starts last 8 jobs, and 8 plugins are not downloaded. I'll make PR from https://github.com/matsuhav/minpac/commit/de2dfbdb7440b562c2122c238890b76312a9b210

netmute commented 5 years ago

I tried redir. This is what I got so far:

function! PackUpdate() abort
  redir >> /dev/stdout
  call PackInit()
  call minpac#update('', {'do': 'q'})
  redir END
endfunction

I doesn't print anything tho.

netmute commented 5 years ago

I found something that works:

function! PackUpdate() abort
  call PackInit()
  call minpac#update('', {'do': 'redir! > $HOME/.vim.update | call minpac#status() | print | redir END | qa'})
endfunction

You can call it like this: vim "+call PackUpdate()" && cat .vim.update | xargs