Parcourir la source

New option: g:startify_session_before_save

Execute commands before saving the session. Useful for cleaning up.

Closes #222.
Marco Hinz il y a 9 ans
Parent
commit
3bd270a3f2
2 fichiers modifiés avec 19 ajouts et 1 suppressions
  1. 4 0
      autoload/startify.vim
  2. 15 1
      doc/startify.txt

+ 4 - 0
autoload/startify.vim

@@ -274,6 +274,10 @@ function! startify#session_write(spath)
       execute 'silent! argdelete' fnameescape(arg)
     endif
   endfor
+  " clean up session before saving it
+  for cmd in get(g:, 'startify_session_before_save', [])
+    execute cmd
+  endfor
 
   let ssop = &sessionoptions
   set sessionoptions-=options

+ 15 - 1
doc/startify.txt

@@ -110,6 +110,7 @@ default values.
 
     Sessions:~
     |g:startify_session_autoload|
+    |g:startify_session_before_save|
     |g:startify_session_delete_buffers|
     |g:startify_session_dir|
     |g:startify_session_persistence|
@@ -233,7 +234,6 @@ The number of files to list.
 >
     let g:startify_update_oldfiles = 0
 <
-
 Usually |v:oldfiles| only gets updated when Vim exits. Using this option updates
 it on-the-fly, so that :Startify is always up-to-date.
 
@@ -250,6 +250,20 @@ This also works if you open a bookmarked directory.
 
 Great way to create a portable project folder.
 
+------------------------------------------------------------------------------
+                                                *g:startify_session_before_save*
+>
+    let g:startify_session_before_save = []
+<
+This is a list of commands to be executed before saving a session.
+
+Example:
+>
+    let g:startify_session_before_save = [
+        \ 'echo "Cleaning up before saving.."',
+        \ 'silent! NERDTreeTabsClose'
+        \ ]
+<
 ------------------------------------------------------------------------------
                                                 *g:startify_session_persistence*
 >