From 7ce625aa26cb340d9837c4b7e7049a09a9abead7 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Wed, 28 Nov 2018 15:35:38 +0200 Subject: [PATCH] Evaluate savevars early --- autoload/startify.vim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/autoload/startify.vim b/autoload/startify.vim index 077fca9..26cf575 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -263,6 +263,11 @@ endfunction " Function: #session_write {{{1 function! startify#session_write(spath) + " preserve existing variables from savevars + if exists('g:startify_session_savevars') + let savevars = map(filter(copy(g:startify_session_savevars), 'exists(v:val)'), '"let ". v:val ." = ". strtrans(string(eval(v:val)))') + endif + " if this function is called while being in the Startify buffer " (by loading another session or running :SSave/:SLoad directly) " switch back to the previous buffer before saving the session @@ -308,9 +313,9 @@ function! startify#session_write(spath) endfor endif - " put existing variables from savevars into session file - if exists('g:startify_session_savevars') - call append(line('$')-3, map(filter(copy(g:startify_session_savevars), 'exists(v:val)'), '"let ". v:val ." = ". strtrans(string(eval(v:val)))')) + " put variables from savevars into session file + if !empty(savevars) + call append(line('$')-3, savevars) endif " put commands from savecmds into session file