Marco Hinz 12 лет назад
Родитель
Сommit
90bfd61296
3 измененных файлов с 20 добавлено и 11 удалено
  1. 16 2
      autoload/startify.vim
  2. 2 2
      doc/startify.txt
  3. 2 7
      plugin/startify.vim

+ 16 - 2
autoload/startify.vim

@@ -8,8 +8,19 @@ if exists('g:autoloaded_startify') || &cp
 endif
 let g:autoloaded_startify = 1
 
+function! startify#get_session_names(lead, ...) abort
+  return map(split(globpath(g:startify_session_dir, '*'.a:lead.'*', '\n')), 'fnamemodify(v:val, ":t")')
+endfunction
+
+function! startify#get_session_names_as_string(lead, ...) abort
+  return join(map(split(globpath(g:startify_session_dir, '*'.a:lead.'*', '\n')), 'fnamemodify(v:val, ":t")'), "\n")
+endfunction
+
 function! startify#save_session(...) abort
-  let spath = g:startify_session_dir .'/'. (exists('a:1') ? a:1 : input('Save under this session name: ')) | redraw
+  let spath = g:startify_session_dir .'/'. (exists('a:1')
+        \ ? a:1
+        \ : input('Save under this session name: ', '', 'custom,startify#get_session_names_as_string'))
+        \ | redraw
   if !filereadable(spath)
     execute 'mksession '. spath | echo 'Session saved under: '. spath
     return
@@ -23,7 +34,10 @@ function! startify#save_session(...) abort
 endfunction
 
 function! startify#load_session(...) abort
-  let spath = g:startify_session_dir .'/'. (exists('a:1') ? a:1 : input('Load this session: ')) | redraw
+  let spath = g:startify_session_dir .'/'. (exists('a:1')
+        \ ? a:1
+        \ : input('Load this session: ', '', 'custom,startify#get_session_names_as_string'))
+        \ | redraw
   if filereadable(spath)
     execute 'source '. spath
   else

+ 2 - 2
doc/startify.txt

@@ -109,8 +109,8 @@ There are only two commands for handling sessions:
 These take either 0 or 1 argument. If you don't specify the session name as an
 argument, they will just ask for it.
 
-You can use <c-u> and <tab> for argument completion. Providing only a part of
-the session name works, too.
+Providing only a part of the session name works too, if you complete the
+argument with either <c-u> or <tab> afterwards.
 
 
 ==============================================================================

+ 2 - 7
plugin/startify.vim

@@ -20,13 +20,8 @@ augroup startify
         \endif
 augroup END
 
-command! -nargs=? -bar -complete=customlist,s:get_session_names SSave call startify#save_session(<f-args>)
-command! -nargs=? -bar -complete=customlist,s:get_session_names SLoad call startify#load_session(<f-args>)
-
-" Function: s:get_session_names {{{1
-function! s:get_session_names(lead, ...) abort
-  return map(split(globpath(g:startify_session_dir, '*'.a:lead.'*', '\n')), 'fnamemodify(v:val, ":t")')
-endfunction
+command! -nargs=? -bar -complete=customlist,startify#get_session_names SSave call startify#save_session(<f-args>)
+command! -nargs=? -bar -complete=customlist,startify#get_session_names SLoad call startify#load_session(<f-args>)
 
 " Function: s:start {{{1
 function! s:start() abort