centos配置vim c++开发环境

好久没从0开始配置vim环境了,今天搞了一下,发现碰到好多问题,整理一下,以便下个环境能继续用。
我的操作系统是redhat,centos7.2
vim代码自动提示插件YouCompleteMe需要vim8和python3版本,centos7.2自带的vim和python都不符合要求,需要重新安装。
查看vim是否支持python3,可以直接按下操作vim --version|head 如果里面有python3且python3前面为"+",则代表支持,否则不支持,需要重新安装vim

环境安装涉及以下几步
1、删除旧的vim配置

yum remove vim-enhanced vim-common vim-filesystem vim-minimal

2、从github上下载安装python3

wget https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tar.xz
tar -xvJf Python-3.8.6rc1.tar.xz 
cd Python-3.8.6rc1
./configure --enable-shared
make
make install

安装后更新bash_profile

PATH=$PATH:$HOME/bin:/usr/local/bin (加这个是因为我默认是root权限安装, python3 make install之后的路径默认是这里)

3、从github上下载vim

git clone https://github.com/vim/vim.git
cd vim
export LDFLAGS="-rdynamic" 
./configure --with-features=huge  --enable-multibyte --enable-rubyinterp=yes --enable-python3interp=yes   --enable-perlinterp=yes --enable-luainterp=yes
make
make install

4、从github上下载bundle

git clone https://github.com/VundleVim/Vundle.vim.git
如果~/.vim文件夹不存在,则直接创建~/.vim/bundle
mv Vundle.vim ~/.vim/bundle/

5、从github上现在NERDTree

cd ~/.vim/bundle
 git clone https://github.com/scrooloose/nerdtree.git

6、从github上现在YouCompleteMe

YouComplete比较特殊,需要python-dev,libffi-dev, libclang-dev

 yum install python-devel
 yum install libffi-devel -y
 yum install libclang-dev
 yum install cmake

之后下载You’CompleteMe

git clone https://github.com/Valloric/YouCompleteMe.git
cd YouCompleteMe
git submodule update --init --recursive
python3 install.py --clang-completer --system-libclang

7、配置vimrc

set encoding=utf-8                                                                                                                                                                    
set nocompatible
filetype on

set completeopt=preview,menu
set cursorline
set autoindent
set ruler
set tabstop=4
set softtabstop=4
set smarttab
set number
set ignorecase
set hlsearch
set incsearch
set laststatus=2


set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'YouCompleteMe'
Plugin 'nerdtree'
call vundle#end()
filetype plugin indent on

autocmd vimenter * NERDTree
wincmd w
autocmd VimEnter * wincmd w
let NERDTreeShowBookMarks=1
autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
#i 以分屏方式打开,文件,文件夹,书签
#gi 以分屏方式打开,文件,文件夹,书签,但是光标停留在NERDTree
#s 水平分屏打开文件,


let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py'
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_complete_in_strings = 1 
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_key_invoke_completion = '<C-a>'

autocmd InsertLeave * if pumvisible() == 0|pclose|endif

猜你喜欢

转载自blog.csdn.net/jxhaha/article/details/108855386