ubuntu下vim安装YouCompleteMe教程

38次阅读

共计 2253 个字符,预计需要花费 6 分钟才能阅读完成。

ubuntu16.4 下 vim 安装 YouCompleteMe 教程

YouCompleteMe 是 vim 代码提示插件


1 首先检查 vim 版本

vim --version

如下所示

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)
Included patches: 1-1689
Extra patches: 8.0.0056
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +tag_binary
+arabic          +file_in_path    +mouse_sgr       +tag_old_static
+autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white
-balloon_eval    +float           +mouse_urxvt     -tcl
-browse          +folding         +mouse_xterm     +terminfo
++builtin_terms  -footer          +multi_byte      +termresponse
+byte_offset     +fork()          +multi_lang      +textobjects
+channel         +gettext         -mzscheme        +timers
+cindent         -hangul_input    +netbeans_intg   +title
-clientserver    +iconv           +packages        -toolbar
-clipboard       +insert_expand   +path_extra      +user_commands
+cmdline_compl   +job             -perl            +vertsplit
+cmdline_hist    +jumplist        +persistent_undo +virtualedit
+cmdline_info    +keymap          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       -python          +vreplace
+cscope          +lispindent      +python3         +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con      -lua             +rightleft       +writebackup
+diff            +menu            -ruby            -X11
+digraphs        +mksession       +scrollbind      -xfontset
-dnd             +modify_fname    +signs           -xim
-ebcdic          +mouse           +smartindent     -xsmp
+emacs_tags      -mouseshape      +startuptime     -xterm_clipboard
+eval            +mouse_dec       +statusline      -xterm_save
+ex_extra        +mouse_gpm       -sun_workshop    -xpm
+extra_search    -mouse_jsbterm   +syntax          
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"

确认 vim 版本至少 7.4 Included patches 大于 1578 并且在 vim 中 输入

:echo has('python') || has('python3')**

如果返回值为 1 代表支持 Python 如果为 0 需获得支持 Python 的 Vim 版本。

2 在 vim 中安装 Vundle

按照文章安装 https://www.jianshu.com/p/769…

3 在使用 Vundle 安装 YouCompleteMe

在.vimrc 中添加以下内容

Plugin 'Valloric/YouCompleteMe'

然后执行如下

git clone https://github.com/ycm-core/YouCompleteMe.git ~/.vim/bundle

在 ~/.vim/bundle/YouCompleteMe 目录下执行

git submodule update --init --recursive

4 安装 cmake

apt install cmake

5 YouCompleteMe 要求 clang 至少 7.0 所以编译 libclang 8.0

clang --version

按照文章编译 https://blog.csdn.net/xingyu9…

6 YouCompleteMe 目录下 安装 c 语言代码提示

cd ~/.vim/bundle/YouCompleteMe
python3 install.py --clang-completer

如图所示表示编译成功

添加.vimrc 配置

vi .vimrc
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'

然后随意创建 .c 文件测试提示

正文完
 0