|
|
@@ -531,16 +531,20 @@ function! s:syntax()
|
|
|
syn match plugStar /^*/
|
|
|
syn match plugMessage /\(^- \)\@<=.*/
|
|
|
syn match plugName /\(^- \)\@<=[^ ]*:/
|
|
|
+ syn match plugSha /\%(: \)\@<=[0-9a-z]\{4,}$/
|
|
|
+ syn match plugTag /(tag: [^)]\+)/
|
|
|
syn match plugInstall /\(^+ \)\@<=[^:]*/
|
|
|
syn match plugUpdate /\(^* \)\@<=[^:]*/
|
|
|
- syn match plugCommit /^ [0-9a-z]\{7} .*/ contains=plugRelDate,plugSha
|
|
|
+ syn match plugCommit /^ [0-9a-z]\{7} .*/ contains=plugRelDate,plugSha,plugTag
|
|
|
syn match plugSha /\(^ \)\@<=[0-9a-z]\{7}/ contained
|
|
|
syn match plugRelDate /([^)]*)$/ contained
|
|
|
syn match plugNotLoaded /(not loaded)$/
|
|
|
syn match plugError /^x.*/
|
|
|
+ syn match plugH2 /^.*:\n-\+$/
|
|
|
syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean
|
|
|
hi def link plug1 Title
|
|
|
hi def link plug2 Repeat
|
|
|
+ hi def link plugH2 Type
|
|
|
hi def link plugX Exception
|
|
|
hi def link plugBracket Structure
|
|
|
hi def link plugNumber Number
|
|
|
@@ -557,6 +561,7 @@ function! s:syntax()
|
|
|
hi def link plugError Error
|
|
|
hi def link plugRelDate Comment
|
|
|
hi def link plugSha Identifier
|
|
|
+ hi def link plugTag Constant
|
|
|
|
|
|
hi def link plugNotLoaded Comment
|
|
|
endfunction
|
|
|
@@ -1993,41 +1998,63 @@ function! s:section(flags)
|
|
|
call search('\(^[x-] \)\@<=[^:]\+:', a:flags)
|
|
|
endfunction
|
|
|
|
|
|
-function! s:diff()
|
|
|
- call s:prepare()
|
|
|
- call append(0, 'Collecting updated changes ...')
|
|
|
- normal! gg
|
|
|
- redraw
|
|
|
+function! s:format_git_log(line)
|
|
|
+ let [sha, refs, subject, date] = split(a:line, nr2char(1))
|
|
|
+ let tag = matchstr(refs, 'tag: [^,)]\+')
|
|
|
+ let tag = empty(tag) ? ' ' : ' ('.tag.') '
|
|
|
+ return printf(' %s%s%s (%s)', sha, tag, subject, date)
|
|
|
+endfunction
|
|
|
|
|
|
- let cnt = 0
|
|
|
- for [k, v] in filter(items(g:plugs), '!has_key(v:val[1], "commit")')
|
|
|
- if !isdirectory(v.dir) || !s:is_managed(k)
|
|
|
- continue
|
|
|
- endif
|
|
|
+function! s:append_ul(lnum, text)
|
|
|
+ call append(a:lnum, ['', a:text, repeat('-', len(a:text))])
|
|
|
+endfunction
|
|
|
|
|
|
- let diff = s:system_chomp('git log --left-only --pretty=format:"%h %s (%cr)" "HEAD...HEAD@{1}"', v.dir)
|
|
|
- if !empty(diff)
|
|
|
- call append(1, '')
|
|
|
- call append(2, '- '.k.':')
|
|
|
- call append(3, map(s:lines(diff), '" ". v:val'))
|
|
|
- let cnt += 1
|
|
|
- normal! gg
|
|
|
+function! s:diff()
|
|
|
+ call s:prepare()
|
|
|
+ call append(0, ['Collecting changes ...', ''])
|
|
|
+ let cnts = [0, 0]
|
|
|
+ let bar = ''
|
|
|
+ let total = filter(copy(g:plugs), 's:is_managed(v:key) && isdirectory(v:val.dir)')
|
|
|
+ call s:progress_bar(2, bar, len(total))
|
|
|
+ for origin in [1, 0]
|
|
|
+ call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:')
|
|
|
+ for [k, v] in reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))'))))
|
|
|
+ let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..'
|
|
|
+ let diff = s:system_chomp('git log --pretty=format:"%h%x01%d%x01%s%x01%cr" '.s:shellesc(range), v.dir)
|
|
|
+ if !empty(diff)
|
|
|
+ let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : ''
|
|
|
+ call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)')))
|
|
|
+ let cnts[origin] += 1
|
|
|
+ endif
|
|
|
+ let bar .= '='
|
|
|
+ call s:progress_bar(2, bar, len(total))
|
|
|
+ normal! 2G
|
|
|
redraw
|
|
|
+ endfor
|
|
|
+ if !cnts[origin]
|
|
|
+ call append(5, ['', 'N/A'])
|
|
|
endif
|
|
|
endfor
|
|
|
+ call setline(1, printf('%d plugin(s) updated.', cnts[0])
|
|
|
+ \ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : ''))
|
|
|
|
|
|
- call setline(1, cnt == 0 ? 'No updates.' : 'Last update:')
|
|
|
- nnoremap <silent> <buffer> <cr> :silent! call <SID>preview_commit()<cr>
|
|
|
- nnoremap <silent> <buffer> o :silent! call <SID>preview_commit()<cr>
|
|
|
- nnoremap <silent> <buffer> X :call <SID>revert()<cr>
|
|
|
- normal! gg
|
|
|
- setlocal nomodifiable
|
|
|
- if cnt > 0
|
|
|
+ if cnts[0] || cnts[1]
|
|
|
+ nnoremap <silent> <buffer> <cr> :silent! call <SID>preview_commit()<cr>
|
|
|
+ nnoremap <silent> <buffer> o :silent! call <SID>preview_commit()<cr>
|
|
|
+ endif
|
|
|
+ if cnts[0]
|
|
|
+ nnoremap <silent> <buffer> X :call <SID>revert()<cr>
|
|
|
echo "Press 'X' on each block to revert the update"
|
|
|
endif
|
|
|
+ normal! gg
|
|
|
+ setlocal nomodifiable
|
|
|
endfunction
|
|
|
|
|
|
function! s:revert()
|
|
|
+ if search('^Pending updates', 'bnW')
|
|
|
+ return
|
|
|
+ endif
|
|
|
+
|
|
|
let name = s:find_name(line('.'))
|
|
|
if empty(name) || !has_key(g:plugs, name) ||
|
|
|
\ input(printf('Revert the update of %s? (y/N) ', name)) !~? '^y'
|