Ubuntu14.04 YouCompleteMe 安装配置方法

1. 安装vim8

https://blog.csdn.net/lwxjkk/article/details/102715822

2. 工具安装

sudo apt install build-essential cmake clang
sudo apt-get install python-dev python3-dev #安装vim8之前安装

3. 下载YouCompleteMe

git clone --recursive https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe

4. 安装YouCompleteMe

cd ~/.vim/bundle/YouCompleteMe
#./install.py --clang-completer --system-libclang
./install.py

5. 编译报错
[100%] Building CXX object ycm/CMakeFiles/ycm_core.dir/versioning.cpp.o
Linking CXX shared library /home/wxli/.vimpkg/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so
[100%] Built target ycm_core
-- The C compiler identification is GNU 4.8.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
-- Could NOT find PythonLibs (missing:  PYTHON_INCLUDE_DIRS) (found version "2.7.6")
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
PYTHON_INCLUDE_DIR2 (ADVANCED)
   used as include directory in directory /home/wxli/.vimpkg/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex

-- Configuring incomplete, errors occurred!
See also "/tmp/regex_build_GphRmg/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.

解决方案:
参考:https://askubuntu.com/questions/479260/cmake-can-not-find-pythonlibs
wxli@ubuntu:~/.vim/bundle/YouCompleteMe$ sudo vim /usr/share/cmake-2.8/Modules/FindPythonLibs.cmake
-set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0)
+set(_PYTHON3_VERSIONS 3.4 3.3 3.2 3.1 3.0)

wxli@ubuntu:~/.vim/bundle/YouCompleteMe$ cmake -G “Unix Makefiles” -DPYTHON_INCLUDE_DIRS=/usr/include/python3.4 DEXTERNAL_LIBCLANG_PATH=/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu/libpython3.4.so . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

-- Using libclang to provide semantic completion for C/C++/ObjC
-- Using external libclang: /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0
-- NOT using clang-tidy for static analysis.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wxli/.vim/bundle/YouCompleteMe

wxli@ubuntu:~/.vim/bundle/YouCompleteMe$ ./install.py
Found Python library: /usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so
Found Python headers folder: /usr/include/python2.7
-- The C compiler identification is GNU 4.8.4
...
Linking CXX shared library /home/wxli/.vimpkg/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so
[100%] Built target ycm_core
-- The C compiler identification is GNU 4.8.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
-- Found PythonLibs: /usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so (found version "2.7.6") 
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/regex_build_2FzBJz
Scanning dependencies of target _regex
[ 50%] [100%] Building C object CMakeFiles/_regex.dir/regex_2/_regex.c.o
Building C object CMakeFiles/_regex.dir/regex_2/_regex_unicode.c.o
Linking C shared library /home/wxli/.vimpkg/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex/regex_2/_regex.so
[100%] Built target _regex
6. 效果图

在这里插入图片描述

7. 配置参考

https://blog.csdn.net/lwxjkk/article/details/102716978

"YouCompleteMe
"自动开启语义补全
let g:ycm_seed_identifiers_with_syntax = 1
"在注释中也开启补全
let g:ycm_complete_in_comments = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 0
"字符串中也开启补全
let g:ycm_complete_in_strings = 1
let g:ycm_collect_identifiers_from_tags_files = 1
"开启基于tag的补全,可以在这之后添加需要的标签路径  
let g:ycm_collect_identifiers_from_tags_files = 1
"开始补全的字符数
let g:ycm_min_num_of_chars_for_completion = 2
"补全后自动关闭预览窗口
let g:ycm_autoclose_preview_window_after_completion = 1
"禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_cache_omnifunc=0
"离开插入模式后自动关闭预览窗口
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
"语法关键字补全
let g:ycm_seed_identifiers_with_syntax = 1  
"在实现和声明之间跳转,并分屏打开
let g:ycm_goto_buffer_command = 'horizontal-split'
nnoremap <Leader>g :YcmCompleter GoTo<CR>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值