aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-10 14:50:06 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-10 14:50:06 +1200
commit5cf226229562e92dd4e2fce2fb6134c82669bdd9 (patch)
tree3c9dbcbc01c7ecb05d85b5cabc9aed8cc780fd89 /vim/autoload
parent226a0d71bb547cc399e00e971789de9b0aceb9f3 (diff)
downloaddotfiles-5cf226229562e92dd4e2fce2fb6134c82669bdd9.tar.gz
dotfiles-5cf226229562e92dd4e2fce2fb6134c82669bdd9.zip
Add session_lazy.vim plugin
Mostly to properly tie down the way I want sessions to behave while I write my book. No documentation yet!
Diffstat (limited to 'vim/autoload')
-rw-r--r--vim/autoload/session_lazy.vim25
1 files changed, 25 insertions, 0 deletions
diff --git a/vim/autoload/session_lazy.vim b/vim/autoload/session_lazy.vim
new file mode 100644
index 00000000..59caae37
--- /dev/null
+++ b/vim/autoload/session_lazy.vim
@@ -0,0 +1,25 @@
+" Choose the filename we'll use for these sessions
+let g:session_lazy#active = 0
+if !exists('g:session_lazy#filename')
+ let g:session_lazy#filename = 'Session.vim'
+endif
+
+" If we started with no arguments, there's no active session, and there's a
+" session file sitting right there, read it
+function! session_lazy#Thaw()
+ if !argc()
+ \ && v:this_session ==# ''
+ \ && filereadable(g:session_lazy#filename)
+ let g:session_lazy#active = 1
+ execute 'source ' . g:session_lazy#filename
+ endif
+endfunction
+
+" Before we quit, if we opened this with a session automatically, save it back
+" again, into the same file
+function! session_lazy#Freeze()
+ if g:session_lazy#active
+ \ && g:session_lazy#filename ==# fnamemodify(v:this_session, ':t')
+ execute 'mksession! ' . g:session_lazy#filename
+ endif
+endfunction