Prechádzať zdrojové kódy

Make :SLoad! source last used session on Unix

Closes https://github.com/mhinz/vim-startify/issues/352
Marco Hinz 7 rokov pred
rodič
commit
0459cd0952
3 zmenil súbory, kde vykonal 15 pridanie a 15 odobranie
  1. 9 11
      autoload/startify.vim
  2. 5 3
      doc/startify.txt
  3. 1 1
      plugin/startify.vim

+ 9 - 11
autoload/startify.vim

@@ -164,7 +164,7 @@ function! startify#insane_in_the_membrane(on_vimenter) abort
 endfunction
 
 " Function: #session_load {{{1
-function! startify#session_load(...) abort
+function! startify#session_load(source_last_session, ...) abort
   if !isdirectory(s:session_dir)
     echomsg 'The session directory does not exist: '. s:session_dir
     return
@@ -177,17 +177,15 @@ function! startify#session_load(...) abort
 
   if a:0
     let spath .= a:1
+  elseif a:source_last_session && !has('win32')
+    let spath .= '__LAST__'
   else
-    if has('win32')
-      call inputsave()
-      let spath .= input(
-            \ 'Load this session: ',
-            \ fnamemodify(v:this_session, ':t'),
-            \ 'custom,startify#session_list_as_string') | redraw
-      call inputrestore()
-    else
-      let spath .= '__LAST__'
-    endif
+    call inputsave()
+    let spath .= input(
+          \ 'Load this session: ',
+          \ fnamemodify(v:this_session, ':t'),
+          \ 'custom,startify#session_list_as_string') | redraw
+    call inputrestore()
   endif
 
   if filereadable(spath)

+ 5 - 3
doc/startify.txt

@@ -742,10 +742,12 @@ Use `:SSave!` or `:SDelete!` to always overwrite or delete an existing session.
 
                                                                *startify-:SLoad*
 >
-    :SLoad [session]
+    :SLoad[!] [session]
 <
-Load a session. If you don't specify a session name, it will either prompt you
-for one (Windows) or load the last used session (Unix).
+Load a session. If you don't specify a session name, it will prompt you for
+one.
+
+If the `!` is given, it tries to source the last used session (only Unix).
 
 Providing only a part of the session name works too, if you complete the
 argument with either <c-d> or <tab> afterwards.

+ 1 - 1
plugin/startify.vim

@@ -56,7 +56,7 @@ function! s:on_vimleavepre()
   endif
 endfunction
 
-command! -nargs=? -bar       -complete=customlist,startify#session_list SLoad   call startify#session_load(<f-args>)
+command! -nargs=? -bar -bang -complete=customlist,startify#session_list SLoad   call startify#session_load(<bang>0, <f-args>)
 command! -nargs=? -bar -bang -complete=customlist,startify#session_list SSave   call startify#session_save(<bang>0, <f-args>)
 command! -nargs=? -bar -bang -complete=customlist,startify#session_list SDelete call startify#session_delete(<bang>0, <f-args>)
 command! -nargs=0 -bar SClose call startify#session_close()