This snippet will check every time you run Vim whether it updated all your Plug
packages for you. It will do this once a week automatically for you.
Add the following to your .vimrc
:
function! OnVimEnter() abort
" Run PlugUpdate every week automatically when entering Vim.
if exists('g:plug_home')
let l:filename = printf('%s/.vim_plug_update', g:plug_home)
if !filereadable(l:filename)
call writefile([], l:filename)
endif
let l:this_week = strftime('%Y_%V')
let l:contents = readfile(l:filename)
if index(l:contents, l:this_week) < 0
call execute('PlugUpdate')
call writefile([l:this_week], l:filename, 'a')
endif
endif
endfunction
autocmd VimEnter * call OnVimEnter()
Thanks man 😄, this is very useful. Much better than execute do this by hand once in a while.