Suggestion: numbers for completion menu?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Suggestion: numbers for completion menu?

MarcWeber
It would be convinient to get an item from the completion menu faster
than <down><down> .. or typing more characters.

What do you think of prepending each item with a number and add a
key-mapping
<c-i><idx> to get the idxth item?
so <c-i>4 would select the 4th.

Would it be convinient to add another mapping space for completions?
mnoremap 2 <c-i>2 ?
m = omni completion _m_enu ?

Or is there another easy way to achieve this ?

Marc
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion: numbers for completion menu?

Robert Lee-7
Marc Weber wrote:

> It would be convinient to get an item from the completion menu faster
> than <down><down> .. or typing more characters.
>
> What do you think of prepending each item with a number and add a
> key-mapping
> <c-i><idx> to get the idxth item?
> so <c-i>4 would select the 4th.
>
> Would it be convinient to add another mapping space for completions?
> mnoremap 2 <c-i>2 ?
> m = omni completion _m_enu ?
>
> Or is there another easy way to achieve this ?
>
> Marc
>
>  
Marc,

Look up (in :he) "omnifunc". For PHP, for example, it is set to
phpcomplete#CompletePHP. That function returns the list of matches. So,
if you remap <c-i>1 through <c-i>9 to your own custom functions, you
should be able to figure out a way of getting what you are looking for I
think. Or even better, you can look in the appropriate plugin file to
get direct access to the autocomplete list (e.g.
vim70/autoload/phpcomplete.vim).

Hope this helps.

-Robert
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion: numbers for completion menu?

MarcWeber
> Marc,
>
> Look up (in :he) "omnifunc". For PHP, for example, it is set to
> phpcomplete#CompletePHP. That function returns the list of matches. So,
> if you remap <c-i>1 through <c-i>9 to your own custom functions, you
> should be able to figure out a way of getting what you are looking for I
> think. Or even better, you can look in the appropriate plugin file to
> get direct access to the autocomplete list (e.g.
> vim70/autoload/phpcomplete.vim).
>
> Hope this helps.
>
> -Robert

Robert:

What about <c-x><c-f> etc?
Of course you can write your own completion for this, too.

The easiest way is mapping <m-x> to repeat("<down>", x) to get the xht
entry. But refreshing the whole completion menu for each <down> slows
down a little bit.

Marc
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion: numbers for completion menu?

Nikolai Weibull-11
In reply to this post by MarcWeber
On 1/23/07, Marc Weber <[hidden email]> wrote:

> It would be convinient to get an item from the completion menu faster
> than <down><down> .. or typing more characters.
>
> What do you think of prepending each item with a number and add a
> key-mapping
> <c-i><idx> to get the idxth item?
> so <c-i>4 would select the 4th.
>
> Would it be convinient to add another mapping space for completions?
> mnoremap 2 <c-i>2 ?
> m = omni completion _m_enu ?
>
> Or is there another easy way to achieve this ?

I've already mentioned this here:

http://thread.gmane.org/gmane.editors.vim.devel/15344/focus=15344

Here's the mappings:

for digit in [1, 2, 3, 4, 5, 6, 8, 9]
  execute 'inoremap <silent> ' . digit . ' <C-R>=pumvisible() ? "' .
        \ repeat('\<lt>C-N>', digit) . '" : "' . digit . '"<CR>'
endfor

However, what I also mention there is that the completion menu
flickers like mad if you use this.  It shouldn't be redrawn quite as
often as it currently is, and not as much of it either.

  nikolai