commit
f11c15e3b7
|
@ -20,7 +20,7 @@ let s:session_dir = resolve(expand(get(g:, 'startify_session_dir',
|
|||
if get(g:, 'startify_session_persistence')
|
||||
autocmd startify VimLeave *
|
||||
\ if exists('v:this_session') && filewritable(v:this_session) |
|
||||
\ execute 'mksession!' fnameescape(v:this_session) |
|
||||
\ call s:session_write(fnameescape(v:this_session)) |
|
||||
\ endif
|
||||
endif
|
||||
|
||||
|
@ -165,13 +165,15 @@ function! startify#session_save(...) abort
|
|||
|
||||
let spath = s:session_dir . s:sep . sname
|
||||
if !filereadable(spath)
|
||||
execute 'mksession '. fnameescape(spath) | echo 'Session saved under: '. spath
|
||||
call s:session_write(fnameescape(spath))
|
||||
echo 'Session saved under: '. spath
|
||||
return
|
||||
endif
|
||||
|
||||
echo 'Session already exists. Overwrite? [y/n]' | redraw
|
||||
if nr2char(getchar()) == 'y'
|
||||
execute 'mksession! '. fnameescape(spath) | echo 'Session saved under: '. spath
|
||||
call s:session_write(fnameescape(spath))
|
||||
echo 'Session saved under: '. spath
|
||||
else
|
||||
echo 'Did NOT save the session!'
|
||||
endif
|
||||
|
@ -514,4 +516,23 @@ function! s:restore_position() abort
|
|||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:session_write {{{1
|
||||
function! s:session_write(spath)
|
||||
execute 'mksession!' a:spath
|
||||
|
||||
if exists('g:startify_session_savevars') || exists('g:startify_session_savecmds')
|
||||
execute 'split' a:spath
|
||||
|
||||
" put existing variables from savevars into session file
|
||||
call append(line('$')-3, map(filter(get(g:, 'startify_session_savevars', []), 'exists(v:val)'), '"let ". v:val ." = ". strtrans(string(eval(v:val)))'))
|
||||
|
||||
" put commands from savecmds into session file
|
||||
call append(line('$')-3, get(g:, 'startify_session_savecmds', []))
|
||||
|
||||
setlocal bufhidden=delete
|
||||
silent update
|
||||
silent hide
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim: et sw=2 sts=2
|
||||
|
|
|
@ -93,6 +93,8 @@ default values.
|
|||
|g:startify_restore_position|
|
||||
|g:startify_empty_buffer_key|
|
||||
|g:startify_enable_special|
|
||||
|g:startify_session_savevars|
|
||||
|g:startify_session_savecmds|
|
||||
|
||||
|
||||
============- *g:startify_session_dir*
|
||||
|
@ -235,6 +237,35 @@ Default: does not exist
|
|||
|
||||
Show <empty buffer> and <quit>.
|
||||
|
||||
============- *g:startify_session_savevars*
|
||||
|
||||
let g:startify_session_savevars = []
|
||||
|
||||
Include a list of variables in here which you would like Startify to save into
|
||||
the session file in addition to what Vim normally saves into the session file.
|
||||
For example, Vim will not normally save all-lowercase global variables, which
|
||||
are common for plugin settings. It may be advisable to include
|
||||
|g:startify_session_savevars| and |g:startify_session_savecmds| into this list
|
||||
so they are saved every time the session saves.
|
||||
|
||||
Example: let g:startify_session_savevars = [
|
||||
\ 'g:startify_session_savevars',
|
||||
\ 'g:startify_session_savecmds',
|
||||
\ 'g:random_plugin_use_feature'
|
||||
\ ]
|
||||
|
||||
============- *g:startify_session_savecmds*
|
||||
|
||||
let g:startify_session_savecmds = []
|
||||
|
||||
Include a list of cmdline commands which Vim will run upon loading the
|
||||
session. This can be useful to set various things (other than variables,
|
||||
|g:startify_session_savevars| above) which Vim may not normally save into the
|
||||
session file, as well as run external commands upon loading a session.
|
||||
|
||||
Example: let g:startify_session_savecmds = [
|
||||
\ 'silent !pdfreader ~/latexproject/main.pdf &'
|
||||
\ ]
|
||||
|
||||
============- *g:startify_restore_position*
|
||||
|
||||
|
|
Loading…
Reference in a new issue