先记录一下YouCompleteMe的安装过程。

按照教程进行安装

1. 安装 vundle

# vundle是vim的包管理器,十分好用
cv@cv: ~$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
cv@cv: ~$ vim ~/.vimrc

写入:

" description: configuration of vim
" author: phillee
" date: 2019-06-04
" email: phillee2016@163.com set nocompatible " be iMproved, required
filetype off " required " set the runtime path to include Vundle and initialize
set runtimepath+=/home/cv/.vim/bundle/Vundle.vim
set runtimepath+=/home/cv/.vim/bundle/ctrlp.vim
set runtimepath+=/home/cv/.vim/bundle/ultisnips call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
" call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end. " plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
Plugin 'Valloric/YouCompleteMe'
Plugin 'vim-syntastic/syntastic'
Plugin 'nvie/vim-flake8' " " Track the engine
Plugin 'SirVer/ultisnips' " Snippets are separated from the engine.
Plugin 'honza/vim-snippets' " plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
" Plugin 'git://git.wincent.com/command-t.git' " git repos on your local machine(i.e. when working on your own plugin)
" Plugin 'file://home/gmarik/path/to/plugin' " The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} " Install L9 and avoid a Naming conflict if you've already install a different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'} " Define bundles via GitHub repo
Bundle 'scrooloose/nerdtree' " All of your Plugins must be added before the following line
call vundle#end() filetype plugin indent on " To ignore plugin indent changes, instead use:
" filetype plugin on " Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append '!' to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append '!' to refresh local cache
" :PluginClean - confirms removal of unused plugins; append '!' to auto-approve removal " see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line set number
set numberwidth= set tabstop=
set background=dark
set showcmd
set encoding=utf- " Default conf file path
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'
" No query for loading ycm_extra_conf.py configuration when vim is opened
let g:ycm_confirm_extra_conf= let g:ycm_use_clangd= set completeopt=longest,menu " path of python Interpreter
let g:ycm_path_to_python_interpreter='/usr/bin/python'
" Enable complete syntax
let g:ycm_seed_identifiers_with_syntax= " Enable or not complete even in the comments
let g:ycm_complete_in_comments=
let g:ycm_collect_identifiers_from_comments_and_strings=
let g:ycm_collect_identifiers_from_tags_files=
let g:ycm_min_num_of_chars_for_completion=
let g:ycm_autoclose_preview_window_after_completion=
let g:ycm_cache_omnifunc=
let g:ycm_complete_in_strings= let python_highlight_all=
syntax on
au BufNewFile,BufRead *.py
\ set tabstop= |
\ set softtabstop= |
\ set shiftwidth= |
\ set textwidth= |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix "Autoclose preview window when leave the insert mode
autocmd InsertLeave * if pumvisible()==|pclose|endif "The user-defined action of the direction keys"
inoremap <expr> <Down> pumvisible()?'\<C-n>':'\<Down>'
inoremap <expr> <Up> pumvisible()?'\<C-p>':'\<Up>'
inoremap <expr> <PageDown> pumvisible()?'\<PageDown>\<C-p>\<C-n>':'\<PageDown>'
inoremap <expr> <PageUp> pumvisible()?'\<PageUp>\<C-p>\<C-n>':'\<PageUp>' " NERDTree config
map <F2> :NERDTreeToggle<CR>
autocmd vimenter * NERDTree
autocmd StdinReadPre * let s:std_in=
autocmd VimEnter * if argc() == && !exists("s:std_in") | NERDTree | endif " This command is to open NERDTree automatically when vim starts up on opening
" a directory.
autocmd VimEnter * if argc() == && isdirectory(argv()[]) && !exists("s:std_in") | exe 'NERDTree' argv()[] | wincmd p | ene | endif " This command is to close vim if the only window left open is a NERDTree.
autocmd bufenter * if(winnr("$")== && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:NERDTreeDirArrowExpandable = '~'
let g:NERDTreeDirArrowCollapsible = '~' " UltiSnips - Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsListSnippets="<c-h>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
let g:UltiSnipsSnippetDirectories=['/home/cv/.vim/bundle/ultisnips/mysnippets/'] " If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"

.vimrc

2. 安装 YouCompleteMe

cv@cv: ~$ sudo apt-get install build-essential cmake
cv@cv: ~$ sudo apt-get install python-dev python3-dev
cv@cv: ~$ cd ~/.vim/bundle/YouCompleteMe
cv@cv: ~/.vim/bundle/YouCompleteMe$ git submodule update --init --recursive
cv@cv: ~/.vim/bundle/YouCompleteMe$ ./install.py --clang-completer

3. 安装 libclang ,否则无法语义补全

cv@cv: ~/.vim/bundle/YouCompleteMe$ sudo apt-get install llvm-3.9 clang-3.9 libclang-3.9-dev libboost-all-dev

4. 编译构建 ycm_core 库

cv@cv: ~/.vim/bundle/YouCompleteMe$ mkdir .ycm_build
cv@cv: ~/.vim/bundle/YouCompleteMe$ cd .ycm_build
cv@cv: ~/.vim/bundle/YouCompleteMe/.ycm_build$ cmake -G "Unix Makefiles" -DUSE_SYSTEM_BOOST=ON -DUSE_SYSTEM_LIBCLANG=ON . ../third_party/ycmd/cpp
cv@cv: ~/.vim/bundle/YouCompleteMe/.ycm_build$ cmake --build . --target ycm_core --config Release

5. 配置文件

主要是 ~/.vimrc 和 ~/.vim/.ycm_extra_conf.py 两个文件

cv@cv: ~/.vim/bundle/YouCompleteMe/.ycm_build$ cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim/

cv@cv: ~/.vim/bundle/YouCompleteMe/.ycm_build$ sudo vim ~/.vim/.ycm_extra_conf.py

添加 C++  头文件和 opencv 头文件索引,写入

'-isystem',
'/usr/include/c++/5.4.0',
'-isystem',
'/usr/local/include/opencv2',

6. 然后安装各种插件

有些插件需要先去 GitHub 上克隆到本地。

打开 vim ,在命令模式下键入下面的插件安装指令,等待完成。

cv@cv: ~$ vim
:PluginInstall

7. 试验一下效果

再次打开 vim ,结果最下面有提示

the ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected error while ...M core library. Type ':YcmToggleLogs ycmd_41013_stderr_cys4wh16.log' to check the logs.

根据提示键入 :YcmToggleLogs ycmd_41013_stderr_cys4wh16.log

# /tmp/ycmd_41013_stderr_cys4wh16.log
Traceback (most recent call last):
File "/home/cv/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/utils.py", line , in ImportAndCheckCore
ycm_core = ImportCore()
File "/home/cv/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/utils.py", line , in ImportCore
import ycm_core as ycm_core
ImportError: /home/cv/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so: undefined symbol: clang_getCompletionFixIt

原来是 clang_getCompletionFixIt 未定义,怎么办呢?

Valloric/YouCompleteMe主页查看了一下,找到了一些线索

根据指示运行 install.sh (因为 install.py 和 install.sh 运行效果一样,当然也可以使用 cv@cv: ~$ python install.py )

cv@cv: ~$ ~/.vim/bundle/YouCompleteMe/install.sh
#!/bin/sh

echo "WARNING: this script is deprecated. Use the install.py script instead." >&

SCRIPT_DIR=$(dirname $ || exit $?)

command_exists() {
command -v "$1" >/dev/null >& ;
} PYTHON_BINARY=python
if command_exists python2; then
PYTHON_BINARY=python2
fi $PYTHON_BINARY "$SCRIPT_DIR/install.py" "$@" || exit $?

install.sh

然后就ok了,现在补全功能可以用了。

  • 如果在执行 ./install.py --clang-completer  的过程中出现HASH mismatch错误
Searching Python 2.7 libraries...
Found Python library: /usr/lib/python2./config-x86_64-linux-gnu/libpython2..so
Found Python headers folder: /usr/include/python2.
-- The C compiler identification is GNU 5.4.
-- The CXX compiler identification is GNU 5.4.
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonLibs: /usr/lib/python2./config-x86_64-linux-gnu/libpython2..so (found suitable version "
2.7.", minimum required is "2.7")
-- Downloading libclang 8.0. from https://dl.bintray.com/micbou/libclang/libclang-8.0.0-x86_64-unknown-l
inux-gnu.tar.bz2
CMake Error at ycm/CMakeLists.txt: (file):
file DOWNLOAD HASH mismatch for file: [/home/cv/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/../clang_archives/libclang-8.0.-x
86_64-unknown-linux-gnu.tar.bz2]
expected hash: [e81a186cd1180ae80c17d67d8d0c101248f8ee032d138cf6f1e95001e733249c]
actual hash: [e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855]
status: [;"SSL connect error"] CMake Error at ycm/CMakeLists.txt: (message):
Cannot find path to libclang in prebuilt binaries -- Configuring incomplete, errors occurred!
See also "/tmp/ycm_build_JVaiLo/CMakeFiles/CMakeOutput.log".
ERROR: the build failed. NOTE: it is *highly* unlikely that this is a bug but rather that this is a problem
with the configuration of your system or a missing dependency. Please carefully
read CONTRIBUTING.md and if you're sure that it is a bug, please raise an issue on
the issue tracker, including the entire output of this script and the invocation
line used to run it.

问题详情可以参考 GitHub上YouCompleteMe  Issues: CMake Error at ycm/CMakeLists.txt: 92(file) file DOWNLOAD HASH mismatch #2353

解决方案:可能是网络的问题,需要手动下载,放到指定位置,重新执行上面的指令即可。下载地址【 https://dl.bintray.com/micbou/libclang/ 】到网站上找到自己需要的版本下载即可。

下载完成后需要放在 ~/.vim/bundle/YouCompleteMe/third_party/ycmd/clang_archives 文件夹下面

mv ~/Downloads/libclang-8.0.-x86_64-unknown-linux-gnu.tar.bz2 ~/.vim/bundle/YouCompleteMe/third_party/ycmd/clang_archives/

Ubuntu16.04VIM无法补全错误记录的更多相关文章

  1. Sublime Text 使用 Emmet 补全错误问题

    Sublime Text安装了Emmet后,使用Tab或者ctrl+e发现补全有问题,如: div.testClass#testId 变成了 div.<testClass id="te ...

  2. 记录一次bug解决过程:else未补全导致数据泄露和代码优化

    一.总结 快捷键ctrl + alt + 四个方向键 --> 倒置屏幕 未补全else逻辑,倒置查询数据泄露 空指针是最容易犯的错误,数据的空指针,可以普遍采用三目运算符来解决 SVN冲突解决关 ...

  3. CozyRSS开发记录6-继续补全订阅内容栏

    CozyRSS开发记录6-继续补全订阅内容栏 1.订阅内容栏布局 按照之前的原型图,把订阅内容栏分成三块.Xaml如下: 2.照葫芦画瓢,完成头部和列表 头部依然使用ColorZone,右侧再放两个按 ...

  4. ROS tab键补全操作出现错误

    ros tab键补全操作出现错误如下: $ roslaunch sp[rospack] Warning: error while crawling /home/hemudu: boost::files ...

  5. Linux --- vim 安装、支持python3的配置、插件自动补全YCM的安装配置及全过程错误总结

    1.git(用来下载vim和相关插件) sudo apt-get install git 2,cmake(用来编译clang-llvm) sudo apt-get install build-esse ...

  6. 在Ubuntu16.04中python环境下实现tab键补全

    1.编写tab.py的代码: 1 #!/usr/bin/env python 2 # python startup file 3 import sys 4 import readline 5 impo ...

  7. IDEA错误的忽略了智能补全代码,导致正确的代码自动提示不出来的问题

    标题说起来有点绕,当今大部分IDE都提供 Alt+Enter 呼出自动补全菜单的功能,IDEA也不例外,今天手残了一下,具体问题如下: 1. 通常我们键入一个自定义类时IDEA会自动提示为红色,表示缺 ...

  8. 删除Chrome地址栏记录中自动补全的网址

    为了删除某个自动补全的网站,多年的历史纪录没了,还浪费我十多分钟,蠢哭_(:з」∠)_ 不是历史记录.不是清除浏览器数据.不是myactivity(谷歌账号)中的历史纪录,直接在书签中搜索,删除,OK ...

  9. centos7安装docker记录+命令补全

    原本用centos6.6部署项目环境,突然想装docker ,使用uname -r 发现内核版本太低,更新内核完后重启起不来了~~~~~,还是用回7吧 21 yum -y install gcc 22 ...

随机推荐

  1. 【JS】382- JavaScript 模块化方案总结

    本文包含两部分,第一部分通过简明的描述介绍什么是 CommonJS.AMD.CMD.UMD.ES Module 以及它们的常见用法,第二部分则根据实际问题指出在正常的 webpack 构建过程中该如何 ...

  2. 实习生4面美团Java岗,已拿offer!(框架+多线程+集合+JVM)

    美团技术一面 1.自我介绍 说了很多遍了,很流畅捡重点介绍完. 2.问我数据结构算法好不好 挺好的(其实心还是有点虚,不过最近刷了很多题也只能壮着胆子充胖子了) 3.找到单链表的三等分点,如果单链表是 ...

  3. C语言每日一练——第6题

    一.题目要求 计算500~800区间素数的个数cnt,并按所求素数的值从大到小的顺序,计算其间隔间的减.加之和,即第1个素数-第2个素数+第3个素数-第4个素数+第5个素数.....的值sum.最后把 ...

  4. Java堆的结构是什么样子的?什么是堆中的永久代(Perm Gen space)?

    JVM的堆是运行时数据区,所有类的实例和数组都是在堆上分配内存.它在JVM启动的时候被创建.对象所占的堆内存是由自动内存管理系统也就是垃圾收集器回收. 堆内存是由存活和死亡的对象组成的.存活的对象是应 ...

  5. django查询中模糊的知识点,filter(blog=blog),filter(username=username).first()--这两者只需一招让你分清QuerySet对象,和用户字典对象

    只需一招让你分清QuerySet对象,和用户字典对象 article_list = models.Article.objects.filter(blog=blog) user_obj = models ...

  6. 《Java基础知识》Java数据类型以及变量的定义

    Java 是一种强类型的语言,声明变量时必须指明数据类型.变量(variable)的值占据一定的内存空间.不同类型的变量占据不同的大小. Java中共有8种基本数据类型,包括4 种整型.2 种浮点型. ...

  7. C++程序设计实验考试准备资料(2019级秋学期)

    程序设计实验考试准备资料 ——傲珂 #include<bits/stdc++.h> C++常用函数: <math.h>头文件 floor() 函数原型:double floor ...

  8. 管程(Moniter): 并发编程的基本心法

    JavaStorm 关注公众号获取更多并发 在吃透 Syncchronized 原理 中介绍了关于 Synchronize的实现原理,无论是同步方法还是同步代码块,无论是ACC_SYNCHRONIZE ...

  9. c++-继承的学习

    继承的基本概念 继承和派生 继承概念 派生类的访问控制(继承三种方式.类三种访问控制.三看原则)综合训练 继承中的构造和析构 类型兼容性原则 继承中的构造和析构 继承中同名成员函数.成员变量处理方法 ...

  10. 南邮CTF - Writeup

    南邮CTF攻防平台Writeup By:Mirror王宇阳 个人QQ欢迎交流:2821319009 技术水平有限~大佬勿喷 ^_^ Web题 签到题: 直接一梭哈-- md5 collision: 题 ...