首页 > 解决方案 > 使用 MacVim 安装 Vim 自动完成插件 YouCompleteMe 后退出代码 -11(Vim 版本 8.1)

问题描述

我想为 Vim 安装自动完成插件 YouCompleteMe。

我按照https://github.com/Valloric/YouCompleteMe/blob/master/README.md#full-installation-guide上的安装指南的说明进行操作

我选择了更简单的选项,不支持 C 系列语言的语义完成。

执行 vim --version 退货

VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 19 2019 12:07:03)
macOS version
Included patches: 1-950
Compiled by Homebrew
Huge version with MacVim 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
+autochdir         +float             +mouse_xterm       +terminal
-autoservername    +folding           +multi_byte        +terminfo
+balloon_eval      -footer            +multi_lang        +termresponse
+balloon_eval_term +fork()            -mzscheme          +textobjects
+browse            +fullscreen        +netbeans_intg     +textprop
++builtin_terms    -gettext           +num64             +timers
+byte_offset       -hangul_input      +odbeditor         +title
+channel           +iconv             +packages          +toolbar
+cindent           +insert_expand     +path_extra        +transparency
+clientserver      +job               +perl              +user_commands
+clipboard         +jumplist          +persistent_undo   +vartabs
+cmdline_compl     +keymap            +postscript        +vertsplit
+cmdline_hist      +lambda            +printer           +virtualedit
+cmdline_info      +langmap           +profile           +visual
+comments          +libcall           -python            +visualextra
+conceal           +linebreak         +python3           +viminfo
+cryptv            +lispindent        +quickfix          +vreplace
+cscope            +listcmds          +reltime           +wildignore
+cursorbind        +localmap          +rightleft         +wildmenu
+cursorshape       +lua               +ruby              +windows
+dialog_con_gui    +menu              +scrollbind        +writebackup
+diff              +mksession         +signs             -X11
+digraphs          +modify_fname      +smartindent       -xfontset
+dnd               +mouse             +startuptime       +xim
-ebcdic            +mouseshape        +statusline        -xpm
+emacs_tags        +mouse_dec         -sun_workshop      -xsmp
+eval              -mouse_gpm         +syntax            -xterm_clipboard
+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save
+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: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -L.  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -framework Ruby

我添加了行

Plugin 'Valloric/YouCompleteMe'

到我的 .vimrc,然后是 Vim 命令

:PluginInstall

执行没有错误。

如果我随后启动 Vim,则会显示以下错误消息:

The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code -11. Type ':YcmToggleLogs ycmd_62275_stderr_menu0zqa.log' to check the logs.

这里提到的日志文件是空的。有谁知道这里有什么问题?

我知道 StackOverflow 和 Github 上还有很多其他关于非常相似的问题的问题。但是由于我在过去的 3 个小时里都在浏览这些内容并试图让插件正常工作但没有成功,如果这不会被标记为重复,我会很高兴,并且非常感谢每一个回复。

标签: vimmacvimyoucompletemevundle

解决方案


https://valloric.github.io/YouCompleteMe/#faq

YCM 不适用于我的 Anaconda Python 设置

Anaconda 通常与 YCM 使用的预构建 libclang 不兼容,因此不受支持。解决此问题的推荐方法是运行 /path/to/real/python install.py(例如 /usr/bin/python install.py)。

如果您想在 Anaconda 项目中完成,请将 .ycm_extra_conf.py 文件中的解释器路径选项指向 Anaconda Python 的路径,例如

def Settings(**kwargs):
  return {
    'interpreter_path': '/path/to/anaconda/python'
  }

有关更多详细信息,请参阅Python 语义完成部分


推荐阅读