-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvim-outdated-plugins.vim
More file actions
66 lines (51 loc) · 1.65 KB
/
vim-outdated-plugins.vim
File metadata and controls
66 lines (51 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
if !exists('g:outdated_plugins_silent_mode')
let g:outdated_plugins_silent_mode = 0
endif
function! s:JobHandler(job_id, data, event) dict
if (str2nr(join(a:data)) != 0)
let g:pluginsToUpdate += 1
endif
endfunction
function! s:CalculateUpdates(job_id, data, event) dict
let l:numberOfcheckedPlugins = 0
let l:command = ""
for key in keys(g:plugs)
let l:command .= '(git -C ' . g:plugs[key].dir . ' rev-list HEAD..origin --count)'
let l:numberOfcheckedPlugins += 1
if l:numberOfcheckedPlugins != len(keys(g:plugs))
let l:command .= ' &&'
endif
endfor
call async#job#start([ 'bash', '-c', l:command], s:calculateCallbacks)
endfunction
function! s:DisplayResults(job_id, data, event) dict
if g:pluginsToUpdate > 0
echom 'Plugins to update: ' . g:pluginsToUpdate
else
if !g:outdated_plugins_silent_mode
echom 'All plugins up-to-date'
endif
endif
endfunction
let s:remoteUpdateCallbacks = {
\ 'on_exit': function('s:CalculateUpdates')
\ }
let s:calculateCallbacks = {
\ 'on_stdout': function('s:JobHandler'),
\ 'on_exit': function('s:DisplayResults')
\ }
function! CheckForUpdates()
let g:pluginsToUpdate = 0
let l:command = ""
" TODO check only activated plugins and not all downloaded
let l:numberOfcheckedPlugins = 0
for key in keys(g:plugs)
let l:command .= 'git -C ' . g:plugs[key].dir . ' remote update > /dev/null'
let l:numberOfcheckedPlugins += 1
if l:numberOfcheckedPlugins != len(keys(g:plugs))
let l:command .= ' &'
endif
endfor
call async#job#start([ 'bash', '-c', l:command], s:remoteUpdateCallbacks)
endfunction
au VimEnter * call CheckForUpdates()