ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.45k stars 2.81k forks source link

Hitting 'Enter' doesn't select item from the dropdown menu in Vim 8.1 #3030

Closed 0xadb closed 6 years ago

0xadb commented 6 years ago

Issue Prelude

Issue Details

On Debian 9.4 I upgraded Vim from 8.0 (from repo) to 8.1 (from sources, following instructions from Full Installation Guide), i.e.:

  1. Create main.cpp with this code:
    
    struct Struct
    {
    int intValue;
    char * strValue;
    };

int main () { Struct s; s // enter '.', select an item and hit 'Enter' return 0; }



2. After 's' enter '.', select a suggestion from dropdown menu and hit 'Enter'

* What did you expect to happen?

On vim 8.0 selecting menu item and pressing Enter led to menu collapsing. It was convenient.

* What actually happened?

Before hitting Enter:
![0-before-hitting-enter](https://user-images.githubusercontent.com/13456740/40296895-b6446d7e-5ce6-11e8-996e-dda614eb7c29.png)
After hitting Enter
![1-after-hitting-enter](https://user-images.githubusercontent.com/13456740/40296902-bc51eac0-5ce6-11e8-8316-448c7d39875a.png)

# Diagnostic data

## Output of `vim --version`

VIM - Vi IMproved 8.1 (2018 May 17, compiled May 19 2018 11:58:46)
Included patches: 1
Compiled by user@box
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
+balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
+browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          +toolbar
+cindent           +insert_expand     +path_extra        +user_commands
+clientserver      +job               +perl              +vertsplit
+clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           -python            +vreplace
+conceal           +linebreak         +python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       +lua               +ruby              +X11
+dialog_con_gui    +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             +xim
+digraphs          +modify_fname      +smartindent       +xpm
+dnd               +mouse             +startuptime       +xsmp_interact
-ebcdic            +mouseshape        +statusline        +xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              -mouse_gpm         +syntax
+ex_extra          -mouse_jsbterm     +tag_binary
+extra_search      +mouse_netterm     +tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/opt/vim-8.1/share/vim"
 f-b for $VIMRUNTIME: "/opt/vim-8.1/share/vim/vim81"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -ldl  -L/usr/lib -llua5.1 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.24/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm  -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm

## Output of `YcmDebugInfo`

Printing YouCompleteMe debug information...
-- Client logfile: /tmp/ycm_c0qz25yi.log
-- Server Python interpreter: /usr/bin/python3.5
-- Server Python version: 3.5.3
-- Server has Clang support compiled in: True
-- Clang version: clang version 6.0.0 (tags/RELEASE_600/final)
-- Extra configuration file found and loaded
-- Extra configuration path: /home/user/.ycm_extra_conf.py
-- C-family completer debug information:
--   Compilation database path: None
--   Flags: ['-Wall', '-Wextra', '-Werror', '-Wc++98-compat', '-Wno-long-long', '-Wno-va
riadic-macros', '-fexceptions', '-DNDEBUG', '-DUSE_CLANG_COMPLETER', '-std=c++11', '-x',
 'c++', '-isystem', '/home/user/../BoostParts', '-isystem', '/System/Library/Framew
orks/Python.framework/Headers', '-isystem', '/home/user/../llvm/include', '-isystem
', '/home/user/../llvm/tools/clang/include', '-I', '/home/user/.', '-I', '/hom
e/user/./ClangCompleter', '-isystem', '/home/user/./tests/gmock/gtest', '-isys
tem', '/home/user/./tests/gmock/gtest/include', '-isystem', '/home/user/./test
s/gmock', '-isystem', '/home/user/./tests/gmock/include', '-resource-dir=/home/bere
govoy/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../clang_includes', '-fspell-check
ing']
--   Translation unit: /home/user/playground/ycm_test/main.cpp
-- Server running at: http://127.0.0.1:58487
-- Server process ID: 21461
-- Server logfiles:
--   /tmp/ycmd_58487_stdout_vlihtjga.log
--   /tmp/ycmd_58487_stderr_jwq1mtmn.log

## Contents of YCM, ycmd and completion engine logfiles

[ycm_c0qz25yi.log](https://github.com/Valloric/YouCompleteMe/files/2021719/ycm_c0qz25yi.log)
[ycmd_58487_stderr_jwq1mtmn.log](https://github.com/Valloric/YouCompleteMe/files/2021720/ycmd_58487_stderr_jwq1mtmn.log)
[ycmd_58487_stdout_vlihtjga.log](https://github.com/Valloric/YouCompleteMe/files/2021721/ycmd_58487_stdout_vlihtjga.log)

## OS version, distribution, etc.

$ uname -a
Linux box 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 GNU/Linux

$ cat /etc/debian_version
9.4

[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md
[readme]: https://github.com/Valloric/YouCompleteMe/blob/master/README.md
[faq]: https://github.com/Valloric/YouCompleteMe/blob/master/README.md#faq
[search]: https://www.google.com/search?q=site%3Ahttps%3A%2F%2Fgithub.com%2FValloric%2FYouCompleteMe%2Fissues%20python%20mac
[gist]: https://gist.github.com/
micbou commented 6 years ago

I can't reproduce the issue. Did you remap the <Enter> key? Does the command

:inoremap <Enter>

return anything? By default, the <Enter> key should always insert a new line even in completion mode. If you want this key to confirm the selection instead of inserting a new line, you should add it to the g:ycm_key_list_stop_completion option:

let g:ycm_key_list_stop_completion = [ '<C-y>', '<Enter>' ]
micbou commented 6 years ago

By the way, you should be able to install YCM with the install.py script instead of following the full instructions on Debian. The command

./install.py --clang-completer

should work. Don't worry if it's downloading the Clang binaries for Ubuntu 14.04. They are compatible with Debian.

0xadb commented 6 years ago

:inoremap <Enter>

i * pumvisible() ? "\" : "\u\"

I am a moron, totally forgot about OmniCompletion enabled:

"" Enable OmniCompletion
" http://vim.wikia.com/wiki/Omni_completion
filetype plugin on
set omnifunc=syntaxcomplete#Complete
" "
" " " Configure menu behavior
" " " http://vim.wikia.com/wiki/VimTip1386
set completeopt=longest,menuone
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <expr> <C-n> pumvisible() ? '<C-n>' :
  \ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <M-,> pumvisible() ? '<C-n>' :
  \ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'

I'm sorry and thank you.

Works now as I expect it to.