Skip to content

Commit 3d0d161

Browse files
committed
Add command completion.
1 parent de17adc commit 3d0d161

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

autoload/startuptime.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,9 @@ function! s:Options(args) abort
838838
\ 'tries': g:startuptime_tries,
839839
\ }
840840
let l:idx = 0
841+
" WARN: Any new/removed/changed arguments below should have corresponding
842+
" updates below in the startuptime#CompleteOptions function and the
843+
" startuptime#StartupTime usage documentation.
841844
while l:idx <# len(a:args)
842845
let l:arg = a:args[l:idx]
843846
if l:arg ==# '--help'
@@ -870,6 +873,21 @@ function! s:Options(args) abort
870873
return l:options
871874
endfunction
872875

876+
" A 'custom' completion function for :StartupTime. A 'custom' function is used
877+
" instead of a 'customlist' function, for the automatic filtering that is
878+
" conducted for the former, but not the latter.
879+
function! startuptime#CompleteOptions(...) abort
880+
let l:args = [
881+
\ '--help',
882+
\ '--other-events', '--no-other-events',
883+
\ '--self', '--no-self',
884+
\ '--sort', '--no-sort',
885+
\ '--sourcing-events', '--no-sourcing-events',
886+
\ '--tries',
887+
\ ]
888+
return join(l:args, "\n")
889+
endfunction
890+
873891
" Usage:
874892
" :StartupTime
875893
" \ [--sort] [--no-sort]

plugin/startuptime.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let s:save_cpo = &cpo
77
set cpo&vim
88

99
if !exists(':StartupTime')
10-
command -nargs=* StartupTime
10+
command -nargs=* -complete=custom,startuptime#CompleteOptions StartupTime
1111
\ :call startuptime#StartupTime(<q-mods>, <f-args>)
1212
endif
1313

0 commit comments

Comments
 (0)