Evaluate savevars early

This commit is contained in:
Sergey Vlasov 2018-11-28 15:35:38 +02:00 committed by Marco Hinz
parent 53c8799ad0
commit 7ce625aa26

View file

@ -263,6 +263,11 @@ endfunction
" Function: #session_write {{{1 " Function: #session_write {{{1
function! startify#session_write(spath) 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 " if this function is called while being in the Startify buffer
" (by loading another session or running :SSave/:SLoad directly) " (by loading another session or running :SSave/:SLoad directly)
" switch back to the previous buffer before saving the session " switch back to the previous buffer before saving the session
@ -308,9 +313,9 @@ function! startify#session_write(spath)
endfor endfor
endif endif
" put existing variables from savevars into session file " put variables from savevars into session file
if exists('g:startify_session_savevars') if !empty(savevars)
call append(line('$')-3, map(filter(copy(g:startify_session_savevars), 'exists(v:val)'), '"let ". v:val ." = ". strtrans(string(eval(v:val)))')) call append(line('$')-3, savevars)
endif endif
" put commands from savecmds into session file " put commands from savecmds into session file