Skip to content

Commit

Permalink
execute git pull on BufEnter
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-h21 committed Nov 9, 2021
1 parent ef5096c commit 8bc60a0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion after/ftplugin/vimwiki.vim
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ augroup vimwiki
endfunction

function! My_exit_cb(channel,msg )
echom "Sync done"
echom "[vimiwiki sync] Sync done"
execute 'checktime'
endfunction

Expand All @@ -59,6 +59,7 @@ augroup vimwiki
" we should add some error handling
function! s:pull_changes()
if g:zettel_synced==0
echom "[vimwiki sync] pulling changes"
let g:zettel_synced = 1
if has("nvim")
let gitjob = jobstart("git -C " . g:zettel_dir . " pull origin " . g:vimwiki_sync_branch, {"exit_cb": "My_exit_cb", "close_cb": "My_close_cb"})
Expand Down Expand Up @@ -94,6 +95,7 @@ augroup vimwiki
" sync changes at the start
au! VimEnter * call <sid>pull_changes()
au! BufRead * call <sid>pull_changes()
au! BufEnter * call <sid>pull_changes()
" auto commit changes on each file change
au! BufWritePost * call <sid>git_action("git -C " . g:zettel_dir . " add . ; git -C " . g:zettel_dir . " commit -m \"Auto commit + push. " . strftime('%c') . "\"")
" push changes only on at the end
Expand Down

0 comments on commit 8bc60a0

Please sign in to comment.