New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does deoplete require `menuone`? I'd like to use `menu`. #872

Closed
kiryph opened this Issue Nov 8, 2018 · 11 comments

Comments

Projects
None yet
2 participants
@kiryph
Contributor

kiryph commented Nov 8, 2018

Afaik, deoplete has hardcoded menuone here

function! deoplete#mapping#_set_completeopt() abort
if exists('g:deoplete#_saved_completeopt')
return
endif
let g:deoplete#_saved_completeopt = &completeopt
set completeopt-=longest
set completeopt+=menuone
set completeopt-=menu
if &completeopt !~# 'noinsert\|noselect'
set completeopt+=noselect
endif
endfunction

and overwrites a user setting set completeopt=menu.

I have checked old issues. But it is not clear if it is required or just many users prefer to use menuone.

@Shougo

This comment has been minimized.

Owner

Shougo commented Nov 8, 2018

It is required.
Because menu behavior overwrites your input text.
It conflicts with auto completion.

@Shougo Shougo closed this Nov 8, 2018

@kiryph

This comment has been minimized.

Contributor

kiryph commented Nov 8, 2018

Because menu behavior overwrites your input text.

This sounds indeed like I cannot use menu. However, vim help is not so clear about this

   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.

Right now, I manually changed it in the deoplete source tree. When I find a specific situation where it does not work as expected, I will add this to this thread, because right now I have not encountered a problem.

Thanks for your feedback.

@Shougo

This comment has been minimized.

Owner

Shougo commented Nov 8, 2018

menu does not use popup menu if it is only one candidate

equals

You input text will be overwritten if it is only one candidate.

It is not accepted for auto completion plugin.

@Shougo

This comment has been minimized.

Owner

Shougo commented Nov 8, 2018

menu is added for shell like manual completion.
It inserts the first candidate automatically.

@kiryph

This comment has been minimized.

Contributor

kiryph commented Nov 8, 2018

You input text will be overwritten if it is only one candidate.
It inserts the first candidate automatically.

This is very convincing why it is not possible to set menu.

However, I cannot confirm this.

What about the settings noinsert and noselect? Are they also relevant for this?

@Shougo

This comment has been minimized.

Owner

Shougo commented Nov 8, 2018

What about the settings noinsert and noselect? Are they also relevant for this?

It does not work for menu option. Because it is for completion menu.

@Shougo

This comment has been minimized.

Owner

Shougo commented Nov 8, 2018

However, I cannot confirm this.

Hm. I don't understand this.
Please create the minimal init.vim with the reproduce-able instructions.
I will check your behavior.

@kiryph

This comment has been minimized.

Contributor

kiryph commented Nov 8, 2018

MWE

❯ mvim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 14 2018 05:28:49)
macOS version
Included patches: 1-280
~/.vim
❯ tree -L 3
.
├── autoload
│   └── plug.vim
├── plugged
│   ├── deoplete.nvim
│   │   ├── LICENSE
│   │   ├── Makefile
│   │   ├── README.md
│   │   ├── autoload
│   │   ├── codecov.yml
│   │   ├── doc
│   │   ├── plugin
│   │   ├── rplugin
│   │   └── test
│   ├── nvim-yarp
│   │   ├── LICENSE
│   │   ├── README.md
│   │   ├── autoload
│   │   └── pythonx
│   └── vim-hug-neovim-rpc
│       ├── LICENSE
│       ├── README.md
│       ├── autoload
│       └── pythonx
└── vimrc

14 directories, 10 files
cat ~/.vim/vimrc
call plug#begin('~/.vim/plugged')
if has('nvim')
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
  Plug 'Shougo/deoplete.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
endif
call plug#end()

let g:deoplete#enable_at_startup = 1

inoremap <silent><expr> <TAB>
		\ pumvisible() ? "\<C-n>" :
		\ <SID>check_back_space() ? "\<TAB>" :
		\ deoplete#mappings#manual_complete()

function! s:check_back_space() abort "{{{
	let col = col('.') - 1
	return !col || getline('.')[col - 1]  =~ '\s'
endfunction"}}}
~/.vim/plugged/deoplete.nvim master*
❯ g diff
diff --git a/autoload/deoplete/mapping.vim b/autoload/deoplete/mapping.vim
index 7071a94..0f80ee0 100644
--- a/autoload/deoplete/mapping.vim
+++ b/autoload/deoplete/mapping.vim
@@ -31,8 +31,8 @@ function! deoplete#mapping#_set_completeopt() abort
   endif
   let g:deoplete#_saved_completeopt = &completeopt
   set completeopt-=longest
-  set completeopt+=menuone
-  set completeopt-=menu
+  set completeopt-=menuone
+  set completeopt+=menu
   if &completeopt !~# 'noinsert\|noselect'
     set completeopt+=noselect
   endif

Reproduce-able Instructions

  1. open new empty buffer
  2. insert a word averylongword
  3. go to next line, enter avery

screen shot 2018-11-08 at 14 34 43

  1. no popup menu visible (menu, single candidate): complete manually with <tab>. (for some reason I have to press <tab><tab very quickly). The most important thing: it does NOT autocomplete avery to averylongword.

Just to make sure pum is shown when there are two or more candidates:

  1. Enter a new word averynewlongword into the third line.
  2. Enter in the 4th line avery, I will get the pum:

screen shot 2018-11-08 at 14 32 01

@Shougo

This comment has been minimized.

Owner

Shougo commented Nov 10, 2018

OK. I have checked the behavior.

The most important thing: it does NOT autocomplete avery to averylongword.

It is noinsert behavior. deoplete overwrites completeopt to noinsert.
Please read the implementation.

What about the settings noinsert and noselect? Are they also relevant for this?
It does not work for menu option. Because it is for completion menu.

So it is wrong. Sorry.

And I have found menu behavior.

  • Default: The first candidate will be inserted. It conflicts with auto completion.
  • noinsert: The first candidate is hide. You can insert it by <C-n>.
  • noselect: The first candidate is hide. You can insert it by <C-y>.

So what is the menu advantage for auto completion?
I have checked all menu behavior and it is bad behavior for auto completion.

@kiryph

This comment has been minimized.

Contributor

kiryph commented Nov 10, 2018

It is noinsert behavior. deoplete overwrites completeopt to noinsert.
Please read the implementation.

I did and obviously I would set noinsert manually if deoplete would not do it.

What about the settings noinsert and noselect? Are they also relevant for this?
It does not work for menu option. Because it is for completion menu.

So it is wrong. Sorry.

No problem.

So what is the menu advantage for auto completion?

First of all, I agree that for autocompletion in general the menu should show up as soon as this is possible, also for a single candidate.

This is not the case anymore with menu and therefore I understand that this is in contradiction with autocompletion and should not be the default. We are talking about a personal setting.

My motivation

is as following and I am pretty sure not everyone agrees with me on that:

(1) Autocompletion menus can be distracting. Therefore, I try to reduce the occasions when the menu becomes visible. Of course, I could disable it in general and only use manual completion.
However, sometimes I like the convenience of the menu automatically showing up.
I try to find a middleground between the convenience of autocompletion and the annoyance of the menu popping up.

(2) I adjust deoplete in different aspects to have only the menu in the most powerful situations, e.g. not to complete hel to hello or a menu with too many entries. This is difficult to do and is actually a subjective matter which means there is no general solution. I am playing around with different settings: minimal length of candidates, number of letters entered, which sources come up, from which files candidates are pulled etc.

(3) I am also becoming more proficient with vim's insert mode completion (:h ins-completion) which are more 'sharp' since they are only 'single source'.

(4) Furthermore, when you spend more time in a programming language, or a text in general, you usually know what you want to complete. This means if there is only a single candidate, I do not need the menu. If I would be wrong about the uniqueness of the completion, the menu would already be visible.

(5) In the case of snippets, I started to use honza's repository of snippets. I also did not take the effort to learn them. Therefore, it was convenient to have the autocompletion to list them.
But again with time, I know now them and removed those which I never use and therefore do not need autocompletion for ultisnips anymore.

Someone has argued against autocompletion in general that it makes you lazy and leads to bad programming:

With a lot of my peers, auto-complete is a huge crutch that does more harm than good. They often miss some of the more fundamental parts of a library or package, and do things the hard way because they keep using the same hammer over and over again. I largely blame auto-complete IDEs because it unintentionally helps you to skip reading the manual.

I'm also going to say that the people with whom I work that rely heavily on auto-complete tend to have far worse software design habits. They don't think about the implications of heavily nested structures and confusing APIs nobody likes to use.

I agree with his standpoint, but only to some extent. Mostly that some people rely exclusively on autocompletion to code. But for most people it is as true as for me that it takes time to learn. In the beginning autocompletion can jump start you. However, one should make the step to switch to manual completion to improve your active knowledge. The primary motivation of completion should then be to increase your typing speed. E.g. cycling through long completion menus can actually have the opposite effect.

Today you encounter many libraries in different languages (e.g. boost libs in c++, python libs such as python standard lib, numpy, scipy, pandas, ....). You are very likely not proficient in all of them despite your possible advanced level in the respective language. Therefore, you will find yourself often in a beginners situation w.r.t. a lib where you appreciate support via completion/autocompletion of what the library offers (incl. docstrings).

Anyhow, I hope I could explain why I do not want/need autocompletion all the time.

And sorry for my long reply and thanks for your time and interest in this issue.

@Shougo

This comment has been minimized.

Owner

Shougo commented Nov 10, 2018

OK. I get it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment