Add PlugDiff command (#17)

This commit is contained in:
Junegunn Choi 2014-04-08 21:43:49 +09:00
parent 8986f87b83
commit f00dacd7bd
2 changed files with 39 additions and 1 deletions

View File

@ -66,6 +66,7 @@ before the call.
| PlugClean[!] | Remove unused directories (bang version will clean without prompt) |
| PlugUpgrade | Upgrade vim-plug itself |
| PlugStatus | Check the status of plugins |
| PlugDiff | See the updated changes from the previous PlugUpdate |
### Options for parallel installer
@ -74,6 +75,12 @@ before the call.
| `g:plug_threads` | 16 | Default number of threads to use |
| `g:plug_timeout` | 60 | Time limit of each task in seconds |
### Keybindings
- `D` - `PlugDiff`
- `S` - `PlugStatus`
- `q` - Close the window
### Example: A small [sensible](https://github.com/tpope/vim-sensible) Vim configuration
```vim

View File

@ -97,6 +97,7 @@ function! plug#begin(...)
command! -nargs=0 -bang PlugClean call s:clean('<bang>' == '!')
command! -nargs=0 PlugUpgrade if s:upgrade() | execute "source ". s:me | endif
command! -nargs=0 PlugStatus call s:status()
command! -nargs=0 PlugDiff call s:diff()
return 1
endfunction
@ -260,6 +261,8 @@ function! s:syntax()
syn match plugX /x/ containedin=plug2 contained
syn match plugDash /^-/
syn match plugName /\(^- \)\@<=[^:]*/
syn match plugRelDate /([^)]\+)$/
syn match plugSha /^ [0-9a-z]\{7}/
syn match plugError /^x.*/
syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean
hi def link plug1 Title
@ -270,6 +273,8 @@ function! s:syntax()
hi def link plugDash Special
hi def link plugName Label
hi def link plugError Error
hi def link plugRelDate Comment
hi def link plugSha Identifier
endfunction
function! s:lpad(str, len)
@ -287,7 +292,9 @@ function! s:prepare()
%d
else
vertical topleft new
noremap <silent> <buffer> q :q<cr>
nnoremap <silent> <buffer> q :q<cr>
nnoremap <silent> <buffer> D :PlugDiff<cr>
nnoremap <silent> <buffer> S :PlugStatus<cr>
let b:plug = 1
let s:plug_win = winnr()
call s:assign_name()
@ -762,6 +769,30 @@ function! s:status()
normal! gg
endfunction
function! s:diff()
call s:prepare()
call append(0, 'Collecting updated changes ...')
for [k, v] in items(g:plugs)
if !isdirectory(v.dir)
continue
endif
execute 'cd '.substitute(v.dir, ' ', '\\ ', 'g')
let diff = system('git log --pretty=format:"%h %s (%cr)" "HEAD@{0}...HEAD@{1}"')
if !v:shell_error && !empty(diff)
call append(1, '')
call append(2, '- '.k.':')
call append(3, map(split(diff, '\n'), '" ". v:val'))
normal! gg
redraw
endif
cd -
endfor
call setline(1, 'Updated changes:')
endfunction
let &cpo = s:cpo_save
unlet s:cpo_save