[new feature] [patch] Added completeselect option

994 views
Skip to first unread message

Shougo

unread,
May 29, 2013, 8:30:12 PM5/29/13
to vim...@googlegroups.com
Hello.

I developed "completeselect" option feature in Vim.

It determines how to select candidate in ins-completion.

The possible values are:
0 select and insert first candidate
1 select first candidate but not insert
2 no selected candidate

I think it is good change for completion.

I tested it in Vim 7.3.1036 and it worked fine.

How do you think about this feature?

completeselect.patch

Marc Weber

unread,
May 29, 2013, 8:39:06 PM5/29/13
to vim_dev
Excerpts from Shougo's message of Thu May 30 02:30:12 +0200 2013:
> How do you think about this feature?
Can you try providing use cases when which option is likely to be
preferred by users? Eg when do you want option "no selecetd candidate" ?

So can you talk about the use case which made you implement this patch?

Marc Weber

Gary Johnson

unread,
May 29, 2013, 8:45:07 PM5/29/13
to vim...@googlegroups.com
I'm not understanding this. Would you please explain how this is
used and what problem it is solving?

Regards,
Gary

Charles

unread,
May 29, 2013, 11:16:54 PM5/29/13
to vim...@googlegroups.com
It forces the user to look into the completion menu before continue typing.

Sometimes when typing I press <C-p> thinking that it will complete a
certain word and just continue typing, but instead it's another word
that is being inserted (that has the same prefix with the word I have
in mind). This option causes the user having to press Enter and or
select the word first before the word is being inserted into the text.

Charles

unread,
May 29, 2013, 11:21:11 PM5/29/13
to vim...@googlegroups.com
Hi,

I think you'll also need to patch runtime/syntax/vim.vim.

Shougo

unread,
May 30, 2013, 2:25:17 AM5/30/13
to vim...@googlegroups.com
> > Hello.
>
> >
>
> > I developed "completeselect" option feature in Vim.
>
> >
>
> > It determines how to select candidate in ins-completion.
>
> >
>
> > The possible values are:
>
> > 0 select and insert first candidate
>
> > 1 select first candidate but not insert
>
> > 2 no selected candidate
>
> >
>
> > I think it is good change for completion.
>
> >
>
> > I tested it in Vim 7.3.1036 and it worked fine.
>
> >
>
> > How do you think about this feature?
>
>
>
> Hi,
>
>
>
> I think you'll also need to patch runtime/syntax/vim.vim.

Thanks. I added it.

> It forces the user to look into the completion menu before continue typing.

Yes.

> Can you try providing use cases when which option is likely to be
preferred by users? Eg when do you want option "no selecetd candidate" ?

And this feature is useful for implementing auto completion plugin.
I implemented some auto completion plugins.

https://github.com/Shougo/neocomplete.vim
https://github.com/Shougo/neocomplcache.vim

And there are other completion plugins like YouCompleteMe.

https://github.com/Valloric/YouCompleteMe

They uses feedkeys() function like below.

call feedkeys( "\<C-X>\<C-U>\<C-P>", 'n' )

But default completion behavior(<C-x><C-u>) is annoying for me.
Because first candidate is selected automatically.
If the option is added, we can implement auto completion more easier.

completeselect.diff

Ben Fritz

unread,
May 30, 2013, 10:50:34 AM5/30/13
to vim...@googlegroups.com

From your description, I think I'd rather see this as an additional value or values supported in 'completeopt'. Currently the only control over what gets inserted is "longest". If it's there, only part of the match text gets inserted, otherwise, the whole first match gets inserted. Why not add a "noinsert" or something, and maybe a "noselect"?

I.e., you could make the list at :help 'completeopt' look like:

menu Use a popup menu to show the possible completions. The
menu is only shown when there is more than one match and
sufficient colors are available. |ins-completion-menu|

menuone Use the popup menu also when there is only one match.
Useful when there is additional information about the
match, e.g., what file it comes from.

longest Only insert the longest common text of the matches. If
the menu is displayed you can use CTRL-L to add more
characters. Whether case is ignored depends on the kind
of completion. For buffer text the 'ignorecase' option is
used.

preview Show extra information about the currently selected
completion in the preview window. Only works in
combination with "menu" or "menuone".

noinsert Do not insert any text for a match until the user selects a
match from the menu. Only works in combination with "menu"
or "menuone". No effect if "longest" is present.

noselect Do not select a match in the menu, force the user to select
one from the menu. Only works in combination with "menu" or
"menuone".

Shougo

unread,
May 30, 2013, 11:25:57 PM5/30/13
to vim...@googlegroups.com
> From your description, I think I'd rather see this as an additional value or values supported in 'completeopt'. Currently the only control over what gets inserted is "longest". If it's there, only part of the match text gets inserted, otherwise, the whole first match gets inserted. Why not add a "noinsert" or something, and maybe a "noselect"?
>
> I.e., you could make the list at :help 'completeopt' look like:
>
> menu Use a popup menu to show the possible completions. The
> menu is only shown when there is more than one match and
> sufficient colors are available. |ins-completion-menu|
>
> menuone Use the popup menu also when there is only one match.
> Useful when there is additional information about the
> match, e.g., what file it comes from.
>
> longest Only insert the longest common text of the matches. If
> the menu is displayed you can use CTRL-L to add more
> characters. Whether case is ignored depends on the kind
> of completion. For buffer text the 'ignorecase' option is
> used.
>
> preview Show extra information about the currently selected
> completion in the preview window. Only works in
> combination with "menu" or "menuone".
>
> noinsert Do not insert any text for a match until the user selects a
> match from the menu. Only works in combination with "menu"
> or "menuone". No effect if "longest" is present.
>
> noselect Do not select a match in the menu, force the user to select
> one from the menu. Only works in combination with "menu" or
> "menuone".

Thank you for the suggestion.
I updated the patch to extend completeopt.
Can you try it?

issue-385.patch

ZyX

unread,
May 31, 2013, 12:47:32 AM5/31/13
to vim...@googlegroups.com
четверг, 30 мая 2013 г., 4:30:12 UTC+4 пользователь Shougo написал:
Don’t know how it is useful, but don’t use magic numbers here. Possible values should be something like “select,insert”, “select” or just empty string. With error or no-op with just “insert” (nothing selected=nothing to insert) and +=/-= support.

ZyX ZyX

unread,
May 31, 2013, 2:05:18 AM5/31/13
to vim...@googlegroups.com

Sorry, missed this part of the discussion when writing my previous reply.

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Shougo

unread,
May 31, 2013, 3:50:16 AM5/31/13
to vim...@googlegroups.com
2013年5月31日金曜日 15時05分18秒 UTC+9 ZyX:
Thanks for the suggestion.

I and Nayuri Aohime(http://www.vim.org/account/profile.php?user_id=66623) updated the patch to remove the magic number.

Could you check it?

To Mr.zhaochai,

> noinsert and noselect are not good names. How about autoinsert and autoselect? Change (default: "menu,preview") => (default: "menu,preview,autoinsert,autoselect")?

Yes. "noinsert" and "noselect" are bad name.
But if users uses below settings, your features will break backward compatibility..

set completeopt=menuone,preview

And in many plugins, it set completeopt directory(not using +=/-= features).

Example: jedi-vim

https://github.com/davidhalter/jedi-vim/blob/master/ftplugin/python/jedi.vim#L39

if g:jedi#auto_vim_configuration
setlocal completeopt=menuone,longest,preview
if len(mapcheck('<C-c>', 'i')) == 0
inoremap <C-c> <ESC>
end
end

I think backward compatibility is very important in Vim world.
completeopt.patch

Marc Weber

unread,
May 31, 2013, 6:26:41 AM5/31/13
to vim_dev
Just thinking about "backward compatibility" - does it make sense to not
be backward compatible forever?

Eg what about

be-backward-compatible-to 7.3 patchlevel 997

Thene there would be a chance to set saner defaults in the future
without breaking vim for old users.

But I agree that this could be implemented as plugin at the beginning.

Marc Weber

UncleBill

unread,
Jun 7, 2013, 2:11:30 AM6/7/13
to vim...@googlegroups.com
在 2013年5月30日星期四UTC+8上午8时39分06秒,MarcWeber写道:
Here is one case
https://github.com/Shougo/neocomplcache.vim/issues/426
Message has been deleted

Pedro Ferrari

unread,
Jan 26, 2015, 7:23:10 PM1/26/15
to vim...@googlegroups.com
https://github.com/Shougo/neocomplete.vim/issues/355


I think this patch would be really useful. Please consider merging. Thanks

Michael Robinson

unread,
May 5, 2015, 4:44:16 PM5/5/15
to vim...@googlegroups.com
Please merge!

Simon

unread,
May 12, 2015, 10:29:12 AM5/12/15
to vim...@googlegroups.com
+1

HD

unread,
May 17, 2015, 5:43:14 AM5/17/15
to vim...@googlegroups.com
+1, this is a badly needed feature

Shougo

unread,
Jun 12, 2015, 8:37:56 AM6/12/15
to vim...@googlegroups.com
Hi, Bram.

I updated the completeopt patch.
It supports complete().

Please include it.
completeopt.patch
Reply all
Reply to author
Forward
0 new messages