From 6cfbbbd6a18a83ae1636422f560ced511f61dea7 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 24 Apr 2013 14:28:35 +0200 Subject: [PATCH] add command argument completion --- doc/startify.txt | 3 +++ plugin/startify.vim | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/startify.txt b/doc/startify.txt index d363eac..e07d178 100644 --- a/doc/startify.txt +++ b/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 and for argument completion. Providing only a part of +the session name works, too. + ============================================================================== 5. About the author *startify-author* diff --git a/plugin/startify.vim b/plugin/startify.vim index 3c8c4d0..cbaf52b 100644 --- a/plugin/startify.vim +++ b/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() -command! -nargs=? -bar SLoad call startify#load_session() - 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() +command! -nargs=? -bar -complete=customlist,s:get_session_names SLoad call startify#load_session() + +" 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