This function obtains the list of possible command line items—those that are visible in wildmenu. It uses Ctrl-a (:help c_CTRL-A) to obtain the info and the fact that it will be inserted in command line history ASAP where last line is yanked and cmd history closed with
<c-f> yy o <cr>
function! GetCmdCompletion(cmd_prefix) let [cwh,ls,v] = [&cwh, &ls, @v] set cwh=1 ls=0 execute 'nn <buffer> z&u :' . a:cmd_prefix . '<c-a><c-f>"vyyo<cr>' normal z&u let res = split(@v) let [&cwh,&ls,@v] = [cwh,ls,v] return res endfunction
This may be used as a source to some plugins (i.e. unite).
This function puts a large amount of text in Vim's command line (depending on the number of completion items). This is not an important issue for single call of the above function but several calls would make this behavior problematic. I didn't find the way to hide Vim's command line or limit the amount of text it displays so far.
https://github.com/MarcWeber/vim-addon-commandline-completion is a related implementation which provides tlib based completion this way