盒子
盒子
文章目录
  1. 环境
  2. 更新yum
  3. 安装可能需要的
  4. 升级gcc
  5. 禁用Anaconda3
  6. 卸载系统原生vim(vim7)
  7. 自己源码安装vim(vim8)
    1. 安装命令
    2. 环境设置
    3. 关于安装
      1. 命令参数
      2. 安装路径
  8. 安装YouCompleteMe
    1. 关于另一个版本的安装方法
  9. 放生Anaconda3
  10. Ref

centos7 anaconda3 安装 youcompleteme

环境

  • CentOS7
  • Anaconda3
  • oh-my-zsh

更新yum

sudo yum upgrade
sudo yum update

安装可能需要的

sudo yum install python-devel
sudo yum install cmake

升级gcc

sudo yum install centos-release-scl -y
sudo yum install devtoolset-3-toolchain -y
sudo yum install gcc-c++

# 如果安装了 oh-my—zsh 则不执行下面这句,否则会切换为bash
sudo scl enable devtoolset-3 bash

禁用Anaconda3

export PATH="/root/anaconda3/bin:$PATH"

.zshrc.bashrc 中注释掉

注释后根目录下执行

source .zshrc
source .bashrc

此时执行

> python -V
>

依旧会显示 Python 3.6.5 :: Anaconda, Inc.

所以我们需要新开一个终端运行下面的命令

卸载系统原生vim(vim7)

yum remove vim

自己源码安装vim(vim8)

安装命令

git clone https://github.com/vim/vim.git
cd vim/src

下面是最关键的一步,多少次失败都是因为这个命令不对!!!

./configure --with-features=huge --enable-pythoninterp=yes --enable-python3interp=yes --with-python3-config-dir=/root/anaconda3/lib/python3.6/config-3.6m-x86_64-linux-gnu
sudo make
sudo make install

--with-python3-config-dir=/root/anaconda3/lib/python3.6/config-3.6m-x86_64-linux-gnu

这条命令根据不同人 anaconda3 安装位置不同会有变动

环境设置

export PATH="/usr/local/bin:$PATH"

配置了 oh-my-zsh 的,添加到 .zshrc

没配置 oh-my-zsh 的,添加到 .bashrc

添加后根目录下执行

source .zshrc
# source .bashrc

关于安装

命令参数

这里列举一些./configure 后面的配置选项

参数 含义
--with-features=huge 支持最大特性
--enable-rubyinterp=yes 打开对ruby编写的插件的支持
--enable-pythoninterp=yes 打开对python编写的插件的支持
--enable-python3interp=yes 打开对python3编写的插件的支持
--enable-luainterp=yes 打开对lua编写的插件的支持
--enable-perlinterp=yes 打开对perl编写的插件的支持
--enable-multibyte=yes 打开多字节支持,可以在Vim中输入中文
--enable-cscope=yes 打开对cscope的支持
--with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu 指定python 路径
--with-python3-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu 指定python3路径
--prefix=/usr/local/vim 指定将要安装到的路径(自行创建)
安装路径
  • 通过 yum install xxx 安装的 软件usr/bin/

  • 通过 源码 安装的 软件usr/local/bin/

当我们通过 yum remove vim 卸载 vim 后再通过源码安装,安装好之后再输入 vim 默认指向的就是 usr/local/bin/ 下的自己安装的

如下

➜  /root whereis vim
vim: /usr/local/bin/vim /usr/share/vim /usr/share/man/man1/vim.1.gz

安装YouCompleteMe

根目录下执行

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

编辑 .vimrc ,加入

" Vundle Setting
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" Plugins
Plugin 'Valloric/YouCompleteMe'

" All of your Plugins must be added before the following line
call vundle#end()
filetype plugin indent on

保存退出

在终端执行

vim +PluginInstall +qall

或者在 vim 中执行

:PluginInstall

等待插件安装完成自动退出

此时会提示 YouCompleteMe 未编译

执行

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

这里只编译了 YouCompleteMeC 族的补全,更多语言的补全命令可见 YouCompleteMe

关于另一个版本的安装方法

  1. 如果已经安装 Vundle 直接跳到 2

    根目录下执行

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

    编辑 .vimrc ,加入

    " Vundle Setting
    set nocompatible
    filetype off
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()

    " let Vundle manage Vundle, required
    Plugin 'VundleVim/Vundle.vim'

    " Plugins
    " Plugin 'Valloric/YouCompleteMe'

    " All of your Plugins must be added before the following line
    call vundle#end()
    filetype plugin indent on

    保存退出执行

    vim +PluginInstall +qall

    或者在 vim 中执行

    :PluginInstall
  2. 安装 YouCompleteMe

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

    编辑 .vimrc ,取消第 11 行的注释,即变为

    Plugin 'Valloric/YouCompleteMe'

    保存退出后执行

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

    DONE

这个安装方法我试了是没有成功的,可能是我环境的原因

亲测在 .vimrc 中添加

> Plugin 'Valloric/YouCompleteMe'
>

并执行

> vim +PluginInstall +qall
>

命令

> git submodule update --init --recursive
>

会失效,故采用 Vundle 安装可直接执行命令

> ./install.py --clang-completer
>

进行编译

放生Anaconda3

export PATH="/root/anaconda3/bin:$PATH"

.zshrc 中的注释去掉

没有安装 oh-my-zsh 的则去掉 .bashrc 中的注释

保存退出后根目录下执行

source .zshrc
source .bashrc

此时执行

> python -V
>

会显示 Python 3.6.5 :: Anaconda, Inc.

DONE

Ref

Centos7安装vim8.0 + YouCompleteMe

支持一下
万一真的就有人扫了呢
  • 微信扫一扫
  • 支付宝扫一扫