Просмотр исходного кода

add command argument completion

Marco Hinz 12 лет назад
Родитель
Сommit
6cfbbbd6a1
2 измененных файлов с 11 добавлено и 3 удалено
  1. 3 0
      doc/startify.txt
  2. 8 3
      plugin/startify.vim

+ 3 - 0
doc/startify.txt

@@ -109,6 +109,9 @@ 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.
+
 
 ==============================================================================
 5. About the author                                            *startify-author*

+ 8 - 3
plugin/startify.vim

@@ -11,9 +11,6 @@ let g:loaded_startify = 1
 " Init {{{1
 let g:startify_session_dir = resolve(expand(get(g:, 'startify_session_dir', '~/.vim/session')))
 
-command! -nargs=? -bar SSave call startify#save_session(<f-args>)
-command! -nargs=? -bar SLoad call startify#load_session(<f-args>)
-
 augroup startify
   autocmd!
   autocmd VimEnter *
@@ -23,6 +20,14 @@ 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
+
 " Function: s:start {{{1
 function! s:start() abort
   setfiletype startify