From d41d90baa07382aaf4f03c0aecebbcdecd5bd9fb Mon Sep 17 00:00:00 2001 From: Rob Miller Date: Mon, 11 Mar 2013 20:18:51 +0000 Subject: [PATCH 1/2] Restore sessions automatically When starting Vim, check if a Session.vim file exists in the current directory. If it does, and if we haven't been passed any arguments, then load the session. --- plugin/obsession.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/obsession.vim b/plugin/obsession.vim index 6d0e848..e5ec69f 100644 --- a/plugin/obsession.vim +++ b/plugin/obsession.vim @@ -61,6 +61,10 @@ endfunction augroup obsession autocmd! autocmd BufEnter,VimLeavePre * exe s:persist() + autocmd VimEnter * + \ if !argc() && empty(v:this_session) && filereadable('Session.vim') | + \ nested source Session.vim | + \ endif augroup END " vim:set et sw=2: From f1a8a0f5c2666ef21b583e12d3edd815f4d6d667 Mon Sep 17 00:00:00 2001 From: Rob Miller Date: Fri, 15 Mar 2013 12:10:39 +0000 Subject: [PATCH 2/2] Fix syntax error when auto-restoring session. When a session file existed, but no manual session was specified, Vim was throwing a syntax error from our autocmd definition. This fixes the problem by moving the `nested` declaration outside the checks for the existence of a session. --- plugin/obsession.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/obsession.vim b/plugin/obsession.vim index e5ec69f..43a7b50 100644 --- a/plugin/obsession.vim +++ b/plugin/obsession.vim @@ -61,9 +61,9 @@ endfunction augroup obsession autocmd! autocmd BufEnter,VimLeavePre * exe s:persist() - autocmd VimEnter * + autocmd VimEnter * nested \ if !argc() && empty(v:this_session) && filereadable('Session.vim') | - \ nested source Session.vim | + \ source Session.vim | \ endif augroup END