From 0347fdf66912bfb0d2071c189e58ece627c45120 Mon Sep 17 00:00:00 2001 From: ZachariasLenz <81169491+ZachariasLenz@users.noreply.github.com> Date: Sat, 3 Apr 2021 04:51:53 +0000 Subject: [PATCH] Allow autoloading sessions from the session directory At the moment we only support autoloading session from the current directory with a Session.vim file. This change will allow Startify to autoload a session if the current directory matches the name of a saved session in the global session directory. --- autoload/startify.vim | 21 +++++++++++++++------ plugin/startify.vim | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/autoload/startify.vim b/autoload/startify.vim index 4c13b49..4fd9feb 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -948,13 +948,22 @@ endfunction " Function: s:check_user_options {{{1 function! s:check_user_options(path) abort - let session = a:path . s:sep .'Session.vim' + if get(g:, 'startify_session_autoload') + let session = a:path . s:sep . 'Session.vim' + if filereadable(glob(session)) + execute 'silent bwipeout' a:path + call startify#session_delete_buffers() + execute 'source' session + return + endif - if get(g:, 'startify_session_autoload') && filereadable(glob(session)) - execute 'silent bwipeout' a:path - call startify#session_delete_buffers() - execute 'source' session - return + let session = startify#get_session_path() . startify#get_separator() . fnamemodify(getcwd(), ':t') + if filereadable(glob(session)) + execute 'silent bwipeout' a:path + call startify#session_delete_buffers() + execute 'source' session + return + endif endif if get(g:, 'startify_change_to_vcs_root') && s:cd_to_vcs_root(a:path) diff --git a/plugin/startify.vim b/plugin/startify.vim index 96bbc5a..6c90f28 100644 --- a/plugin/startify.vim +++ b/plugin/startify.vim @@ -35,8 +35,11 @@ endfunction function! s:on_vimenter() if !argc() && line2byte('$') == -1 + let session = startify#get_session_path() . startify#get_separator() . fnamemodify(getcwd(), ':t') if get(g:, 'startify_session_autoload') && filereadable('Session.vim') source Session.vim + elseif get(g:, 'startify_session_autoload') && filereadable(session) + execute 'source ' . session elseif !get(g:, 'startify_disable_at_vimenter') call startify#insane_in_the_membrane(1) endif