When I start vim and run :messages, I see that vim-outdated-plugins has emitted two times the message:
Messages maintainer: Bram Moolenaar <Bram@vim.org>
All plugins up-to-date
All plugins up-to-date
I would prefer only to get a single message when all checks are done.
I have come up with a solution which works for me but I am not sure if it is implemented job-safe : I mean: I remove a job id from a dict in a callback which I am not sure could lead to a collision.
~/.vim/plugged/vim-outdated-plugins master*
❯ g diff
diff --git a/plugin/vim-outdated-plugins.vim b/plugin/vim-outdated-plugins.vim
index 8d12f4d..5e86b18 100644
--- a/plugin/vim-outdated-plugins.vim
+++ b/plugin/vim-outdated-plugins.vim
@@ -1,14 +1,17 @@
function! s:JobHandler(job_id, data, event) dict
- if (join(a:data) =~ "is behind")
+ if (str2nr(join(a:data)) != 0)
let g:pluginsToUpdate += 1
endif
endfunction
function! s:CalculateUpdates(job_id, data, event) dict
- if g:pluginsToUpdate > 0
- echom 'Plugins to update: ' . g:pluginsToUpdate
- else
- echom 'All plugins up-to-date'
+ call remove(g:check_for_updates_jobids, a:job_id) " Question: lock required?
+ if len(g:check_for_updates_jobids) == 0
+ if g:pluginsToUpdate > 0
+ echom 'Plugins to update: ' . g:pluginsToUpdate
+ else
+ echom 'All plugins up-to-date'
+ endif
endif
endfunction
@@ -21,8 +24,9 @@ function! CheckForUpdates()
let g:pluginsToUpdate = 0
" TODO check only activated plugins and not all downloaded
+ let g:check_for_updates_jobids = {}
for key in keys(g:plugs)
- let job = async#job#start([ 'bash', '-c', "cd " . g:plugs[key].dir ." && git remote update && git status -uno"], s:callbacks)
+ let g:check_for_updates_jobids[async#job#start([ 'bash', '-c', "cd " . g:plugs[key].dir ." && git remote update > /dev/null && git rev-list HEAD..origin --count"], s:callbacks)] = key
endfor
endfunction
Another issue which I think has to be taken into account is when the git command fails.
BTW Issue #11 should easily be resolved by simply removing the lines
I am using vim8 and have configured a minimal setup:
When I start vim and run
:messages
, I see thatvim-outdated-plugins
has emitted two times the message:I would prefer only to get a single message when all checks are done.
I have come up with a solution which works for me but I am not sure if it is implemented job-safe : I mean: I remove a job id from a dict in a callback which I am not sure could lead to a collision.
Another issue which I think has to be taken into account is when the git command fails.
BTW Issue #11 should easily be resolved by simply removing the lines