latest greatest additions
[dotfiles.git] / vim / .vim / after / plugin / vimwiki-git.vim
diff --git a/vim/.vim/after/plugin/vimwiki-git.vim b/vim/.vim/after/plugin/vimwiki-git.vim
new file mode 100644 (file)
index 0000000..680190e
--- /dev/null
@@ -0,0 +1,18 @@
+" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
+" Vimwiki support for having your wiki directory as a git repo.
+
+" We add to the vimwiki group
+if exists("g:vimwiki_list")
+       for w in g:vimwiki_list
+               augroup vimwiki
+                       let home = w['path']."/index.wiki"
+                       " Make sure this window's working dir is the wiki repo dir whenever home.md is opened
+                       au! BufRead home lcd w['path']; echo "enabling vimwiki autogit";
+                       " Also do a git pull whenever home.md is opened
+                       au BufRead home !git pull
+                       let wikifiles = w['path'] . "/*"
+                       " After writing to any file in the wiki dir, add all files in the repo, commit and push
+                       au! BufWritePost wikifiles !git add .;git commit -m "Autocommit and push"; git push
+               augroup END
+       endfor
+endif