瀏覽代碼

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 年之前
父節點
當前提交
b624d3a439
共有 2 個文件被更改,包括 18 次插入0 次删除
  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',
 let s:session_dir      = resolve(expand(get(g:, 'startify_session_dir',
       \ has('win32') ? '$HOME\vimfiles\session' : '~/.vim/session')))
       \ 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: #get_separator {{{1
 function! startify#get_separator() abort
 function! startify#get_separator() abort
   return !exists('+shellslash') || &shellslash ? '/' : '\'
   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
 When the file Session.vim is found in the current directory, it will be shown at
 the top of all lists as entry [0].
 the top of all lists as entry [0].
 
 
+
 ============-
 ============-
 
 
     let g:startify_session_autoload = 0
     let g:startify_session_autoload = 0
@@ -152,6 +153,14 @@ directory.
 
 
 Great way to create a portable project folder.
 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
     let g:startify_change_to_dir = 1