Browse Source

New option: g:startify_session_persistence

Whenever you load/save a session, v:this_session is set automatically.
If this option is enabled and v:this_session exists, the session file
will be updated before exiting Vim.

References #32.
Marco Hinz 12 years ago
parent
commit
b624d3a439
2 changed files with 18 additions and 0 deletions
  1. 9 0
      autoload/startify.vim
  2. 9 0
      doc/startify.txt

+ 9 - 0
autoload/startify.vim

@@ -15,6 +15,15 @@ let s:restore_position = get(g:, 'startify_restore_position')
 let s:session_dir      = resolve(expand(get(g:, 'startify_session_dir',
       \ has('win32') ? '$HOME\vimfiles\session' : '~/.vim/session')))
 
+" Init: autocmds {{{1
+
+if get(g:, 'startify_session_persistence')
+  autocmd startify VimLeave *
+        \ if exists('v:this_session') && filewritable(v:this_session) |
+        \   execute 'mksession!' fnameescape(v:this_session) |
+        \ endif
+endif
+
 " Function: #get_separator {{{1
 function! startify#get_separator() abort
   return !exists('+shellslash') || &shellslash ? '/' : '\'

+ 9 - 0
doc/startify.txt

@@ -142,6 +142,7 @@ The number of files to list.
 When the file Session.vim is found in the current directory, it will be shown at
 the top of all lists as entry [0].
 
+
 ============-
 
     let g:startify_session_autoload = 0
@@ -152,6 +153,14 @@ directory.
 
 Great way to create a portable project folder.
 
+
+============-
+
+    let g:startify_session_persistence = 0
+
+Automatically update sessions before exiting Vim.
+
+
 ============-
 
     let g:startify_change_to_dir = 1