Add plug update reminder
This commit is contained in:
parent
8b0f4e4d83
commit
3bd1e87fd6
2 changed files with 56 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,6 +10,7 @@ vim/vim.symlink/bundle
|
||||||
|
|
||||||
nvim/nvim.symlink/plugged
|
nvim/nvim.symlink/plugged
|
||||||
nvim/nvim.symlink/.netrwhist
|
nvim/nvim.symlink/.netrwhist
|
||||||
|
nvim/nvim.symlink/plugged-update
|
||||||
|
|
||||||
zsh/zsh.symlink/liquidprompt
|
zsh/zsh.symlink/liquidprompt
|
||||||
zsh/zsh.symlink/zsh-completions
|
zsh/zsh.symlink/zsh-completions
|
||||||
|
|
|
@ -238,6 +238,8 @@ nnoremap <leader>ev :call OpenFileWindow($MYVIMRC)<cr>
|
||||||
|
|
||||||
" Second part, every time I write to $MYVIMRC, source it for me.
|
" Second part, every time I write to $MYVIMRC, source it for me.
|
||||||
augroup updateVimrc
|
augroup updateVimrc
|
||||||
|
autocmd!
|
||||||
|
|
||||||
autocmd BufWritePost $MYVIMRC :source $MYVIMRC
|
autocmd BufWritePost $MYVIMRC :source $MYVIMRC
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
@ -355,6 +357,7 @@ endfunction
|
||||||
|
|
||||||
augroup AutoMkdir
|
augroup AutoMkdir
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
autocmd BufNewFile * :call EnsureDirExists()
|
autocmd BufNewFile * :call EnsureDirExists()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
@ -364,6 +367,7 @@ endfunc
|
||||||
|
|
||||||
augroup WindowManagement
|
augroup WindowManagement
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
autocmd WinEnter * call HandleWinEnter()
|
autocmd WinEnter * call HandleWinEnter()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
@ -424,3 +428,54 @@ function! OpenFileWindow(file)
|
||||||
|
|
||||||
return newwinnr
|
return newwinnr
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Remind me to update my plugins every so often. Run a function at startup
|
||||||
|
" that checks when they were last updated.
|
||||||
|
let g:plug_update_file = '~/dotfiles/nvim/nvim.symlink/plugged-update'
|
||||||
|
" Update every two weeks
|
||||||
|
let g:plug_update_timeout = 60 * 60 * 24 * 14
|
||||||
|
|
||||||
|
function! NeedsUpdate(update_file)
|
||||||
|
let now = system('date +%s')
|
||||||
|
|
||||||
|
if !filereadable(a:update_file)
|
||||||
|
return v:true
|
||||||
|
endif
|
||||||
|
|
||||||
|
let contents = readfile(a:update_file)
|
||||||
|
if !exists('contents[0]')
|
||||||
|
return v:true
|
||||||
|
endif
|
||||||
|
|
||||||
|
let updated_at = contents[0]
|
||||||
|
let updated_threshold = now - g:plug_update_timeout
|
||||||
|
|
||||||
|
if updated_at == '' || updated_at < updated_threshold
|
||||||
|
return v:true
|
||||||
|
endif
|
||||||
|
|
||||||
|
return v:false
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
function! UpdatePlugReminder()
|
||||||
|
let file = expand(g:plug_update_file)
|
||||||
|
let now = system('date +%s')
|
||||||
|
if NeedsUpdate(file)
|
||||||
|
let msg = "Your plugins haven't been updated for over two weeks."
|
||||||
|
let msg .= "\n" . "Update plugins now? : "
|
||||||
|
if input(msg, "Y") == "Y"
|
||||||
|
PlugUpdate
|
||||||
|
call writefile([now], file)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
function! StartUp()
|
||||||
|
call UpdatePlugReminder()
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
augroup startUp
|
||||||
|
autocmd!
|
||||||
|
|
||||||
|
autocmd VimEnter * call StartUp()
|
||||||
|
augroup END
|
||||||
|
|
Loading…
Add table
Reference in a new issue