From 3bd270a3f2cab75f7f203a8acdfbdbb2f8544d3a Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 1 Jun 2016 17:40:44 +0200 Subject: [PATCH] New option: g:startify_session_before_save Execute commands before saving the session. Useful for cleaning up. Closes #222. --- autoload/startify.vim | 4 ++++ doc/startify.txt | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/autoload/startify.vim b/autoload/startify.vim index ea19efa..c043fe2 100644 --- a/autoload/startify.vim +++ b/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 diff --git a/doc/startify.txt b/doc/startify.txt index 635dabd..bf4db5f 100644 --- a/doc/startify.txt +++ b/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* >