标签:
YouCompeteMe插件官方地址:Github.
YouCompleteMe是一款功能非常强大的自动补齐插件,如下图:
详细介绍可参考博文Vim下自动补齐插件YouComplete安装与配置。
YouCompleteMe要求Vim版本大于等于7.3。检查Vim版本命令如下:
1 vim --version
1 sudo yum install cmake
下载最新的LLVM、clang 及辅助库源码可用:
1 cd ~/llvm-clang 2 svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm 3 cd llvm/tools 4 svn co http://llvm.org/svn/llvm-project/cfe/trunk clang 5 cd ../.. 6 cd llvm/tools/clang/tools 7 svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra 8 cd ../../../.. 9 cd llvm/projects 10 svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt 11 cd ..
返回~/llvm-clang目录,并新建一个目录llvm-build专门用于编译llvm-clang,使得不污染源码。
1 mkdir llvm-build 2 cd llvm-build/ 3 ../llvm/configure --enable-optimized --enable-targets=host-only --prefix=/usr/clang
建立编译环境
此种配置后,其中--prefix指定llvm-clang安装目录
输入
1 make -j4 // 开始编译 2 sudomakeinstall//进行安装
如要卸载则在该目录下输入
1 sudo make uninstall
安装好后,输入
1 clang -v //查看版本信息:
clang 的标准库————libc++(接口层)和 libc++abi(实现层)需要安装头文件和动态链接库(*.so)。
安装libc++
1 cd ~/llvm-clang 2 svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx 3 cd libcxx/lib 4 ./buildit
头文件已经生成到 ~/llvm-clang/libcxx/include/,要让 clang 找到必须复制到 /usr/include/c++/v1/
1 sudo cp -r ~/llvm-clang/libcxx/include/ /usr/include/c++/v1/
*.so 文件已生成 ~/llvm-clang/libcxx/lib/libc++.so.1.0,要让 clang 访问必须复 制到 /usr/lib/,并创建软链接
1 ln -s ~/llvm-clang/libcxx/lib/libc++.so.1.0 ~/llvm-clang/libcxx/lib/libc++.so.1 2 ln -s ~/llvm-clang/libcxx/lib/libc++.so.1.0 ~/llvm-clang/libcxx/lib/libc++.so 3 sudo cp ~/llvm-clang/libcxx/lib/libc++.so* /usr/lib/
类似,源码安装 libc++abi 的头文件和动态链接库:
1 cd ~/llvm-clang/ 2 svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi 3 cd libcxxabi/lib 4 ./buildit
头文件已经生成到 ~/llvm-clang/libcxxabi/include/,要让 clang 找到必须复制到 /usr/include/c++/v1/
1 cp -r ~/llvm-clang/libcxxabi/include/ /usr/include/c++/v1/
*.so 文件已生成 ~/llvm-clang/libcxx/lib/libc++abi.so.1.0,要让 clang 访问必 须复制到 /usr/lib/,并创建软链接
1 ln -s ~/llvm-clang/libcxxabi/lib/libc++abi.so.1.0 ~/llvm-clang/libcxxabi/lib/libc++abi.so.1 2 ln -s ~/llvm-clang/libcxxabi/lib/libc++abi.so.1.0 ~/llvm-clang/libcxxabi/lib/libc++abi.so 3 sudo cp ~/llvm-clang/libcxxabi/lib/libc++abi.so* /usr/lib/
如果系统没有装有python,则需安装:
1 sudo yum install python-devel
Vundle是Vim的插件管理插件,安装详细请参照Vundle官方网站。
下载YouCompleteMe源码:
1 git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
然后在在vimrc文件中加入:
1 Bundle ‘Valloric/YouCompleteMe‘
执行命令:
cd ~/.vim/bundle/YouCompleteMe ./install.sh --clang-completer
下边配置摘自博文Vim下自动补齐插件YouComplete安装与配置。
1 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 2 " => YouCompleteMe 代码自动补全 3 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 4 Bundle ‘Valloric/YouCompleteMe‘ 5 " youcompleteme 默认tab s-tab 和自动补全冲突 6 " let g:ycm_key_list_select_completion=[‘<c-n>‘] 7 " let g:ycm_key_list_select_completion = [‘<Down>‘] 8 " let g:ycm_key_list_previous_completion=[‘<c-p>‘] 9 " let g:ycm_key_list_previous_completion = [‘<Up>‘] 10 let g:ycm_confirm_extra_conf=0 " 关闭加载.ycm_extra_conf.py提示 11 let g:ycm_complete_in_comments = 1 "在注释输入中也能补全 12 let g:ycm_complete_in_strings = 1 "在字符串输入中也能补全 13 let g:ycm_collect_identifiers_from_tags_files=1 " 开启 YCM 基于标签引擎 14 let g:ycm_collect_identifiers_from_comments_and_strings = 1 "注释和字符串中的文字也会被收入补全 15 let g:ycm_seed_identifiers_with_syntax=1 "语言关键字补全, 不过python关键字都很短,所以,需要的自己打开 16 let g:ycm_collect_identifiers_from_tags_files = 1 17 let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项 18 " 引入,可以补全系统,以及python的第三方包 针对新老版本YCM做了兼容 19 " old version 20 if !empty(glob("~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py")) 21 let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py" 22 endif 23 " new version 24 if !empty(glob("~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py")) 25 let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py" 26 endif 27 28 "mapping 29 nmap <leader>gd :YcmDiags<CR> 30 nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR> " 跳转到申明处 31 nnoremap <leader>gf :YcmCompleter GoToDefinition<CR> " 跳转到定义处 32 nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR> 33 34 " 直接触发自动补全 35 let g:ycm_key_invoke_completion = ‘<C-Space>‘ 36 " 黑名单,不启用 37 let g:ycm_filetype_blacklist = { 38 \ ‘tagbar‘ : 1, 39 \ ‘gitcommit‘ : 1, 40 \}
CentOS 7下的Vim自动补齐插件YouCompleteMe安装及配置
标签:
原文地址:http://www.cnblogs.com/xiehongfeng100/p/4651972.html