vim ycm c++ 环境搭建

写在前面:

系统:

centos 6或7

目的:

安装简单的依赖vim实现python、c++的代码提示、跳转和一些让开发变得更加容易的软件。

1. 下载高版本的vim

起码得8.1,这是ycm的最低配置,别看版本了,直接新下。

git clone https://github.com/vim/vim.git
  ./configure --enable-python3interp=dynamic

git下来是7.4,记得切换版本。需要Python编译时带--enable-shared和-fPIC才行,不能找到.a,得找到.so才可以。

期间缺少 ncurses

yum install -y ncurses-devel.x86_64

2. 配置bunndle

  1. git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim

  2. 修改 .vimrc

  3. set rtp+=~/.vim/bundle/Vundle.vim
    
    call vundle#begin()
    
    Plugin 'VundleVim/Vundle.vim'
    
    call vundle#end()

    3. 打开vim在底行模式下输入 :BundleInstall

3. 安装a.vim

目的:快速切换.h\.cc, 在~/.vim中新建plugin文件夹,放入a.vim即可。

该链接为下载a.vim的链接。https://www.vim.org/scripts/script.php?script_id=31

切换方式:A可以快速切换.h/.cpp

4. 配置ycm

1. 下载ycm

git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
cd ~/.vim/bundle/YouCompleteMe
git submodule update --init --recursive

2. 更改.vimrc

在2.2的第三行和第七行之间配置Plugin

Plugin 'Valloric/YouCompleteMe'

然后在vim地行输入 :BundleInstall,安装完成后道理上是只有提示,没有跳转的,我们需要开启跳转。

3. 编译ycm_core

cd ~/.vim/bundle/YouCompleteMe
./install.py
#这里我们只加了c支持。如果需要其他支持,自行看手册。
#C/C++/Objective-C/Objective-C++:编译时添加--clang-completer
#C#:先安装Mono,编译时添加--cs-completer
#Go:先安装Go,编译时添加--go-completer
#TypeScript:先安装 Node.js and npm,然后使用npm install -g typescript安装TypeScript SDK
#JavaScript: 先安装 Node.js and npm,编译时添加--js-completer
#Rust: 先安装Rust,编译时添加--rust-completer
#Java: 先安装JDK8,编译时添加--java-completer
#全部支持:先安装所有的依赖环境,编译时添加--all

4. 配置.ycm_extra_conf

4.1 这里我们仅以TensorFlow为例,在TensorFlow根目录下创建文件.ycm_extra_conf.py然后加入附录中我的conf,即可。

4.2 问题:

module 'kzwtfuxjvfkgzkj' has no attribute 'FlagsForFile'

4.4 我的ycm config:

flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG ',
'-xc++',
'-std=c++11',

'-isystem',
'/docker/opt/meituan/zhaozheng/code/afo',  #请删除注释,配置为TensorFlow根目录的绝对路径。
'-isystem',
'/docker/opt/meituan/zhaozheng/locals/include/c++/4.8.5', #请删除注释,配置为c++的include目录。
'-isystem',
'/docker/opt/meituan/zhaozheng/locals/include/c++/4.8.5/backward',#请删除注释,配置为c++的include目录中backward目录。
'-isystem',
'/usr/include',
'-isystem',
'/usr/local/include'
]

SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', ]

def FlagsForFile( filename, **kwargs ):
  return {
  'flags': flags,
  'do_cache': True
  }

5. 安装ag

git clone https://github.com/ggreer/the_silver_searcher.git

sh build.sh

缺少pcre

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/pcre-devel-8.32-17.el7.x86_64.rpm

rpm -I pcre-devel-8.32-17.el7.x86_64.rpm

缺少liblzma

yum -y install xz-devel

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值