一个周的摸索。。。要哭了。。。我的vim终于配置好了(没有达到大神级)
不过也是很大的进步!加油!
1、我的环境:
[david@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
2、vim升到8.0
# 移除旧版本sudo yum remove vim -y
# 安装必要组件sudo yum install ncurses-devel python-devel -y
# 下载源码编译安装git clone https://github.com/vim/vim.gitcd vim/src
# 根据自己实际情况设置编译参数./configure --with-features=huge --enable-pythoninterp=yes --enable-cscope --enable-fontset --with-python-config-dir=/usr/lib64/python2.7/config
make
sudo make install
编译参数说明:
–with-features=huge:支持最大特性
–enable-rubyinterp:打开对ruby编写的插件的支持
–enable-pythoninterp:打开对python编写的插件的支持
–enable-python3interp:打开对python3编写的插件的支持
–enable-luainterp:打开对lua编写的插件的支持
–enable-perlinterp:打开对perl编写的插件的支持
–enable-multibyte:打开多字节支持,可以在Vim中输入中文
–enable-cscope:打开对cscope的支持
–with-python-config-dir=/usr/lib64/python2.7/config 指定python 路径
–with-python-config-dir=/usr/lib64/python3.5/config 指定python3路径
------一定要有python支持-----这个没有仔细调研-------
3、Vim默然是安装在/usr/local/bin目录下,所以把该目录加入到PATH,方便terminal全局
sudo nano /etc/profile 打开了一个文件
export PATH=$PATH:/usr/local/bin/vim 在这个文件的最底部加上
source /etc/profile 环境变量生效
4、Vundle是Vim的插件管理工具 Google 直接Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
打开vim vim ~/.vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
"Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
"Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
Bundle 'altercation/vim-colors-solarized'
Plugin 'vim-scripts/OmniCppComplete'
Plugin 'Valloric/YouCompleteMe'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
syntax enable
colorscheme monokai
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
5、执行插件安装
vim +PluginInstall +qall
6、使用monokai 配色方案 :https://github.com/sickill/vim-monokai
mkdir ~/.vim/colors
wget -O ~/.vim/colors/monokai.vim https://raw.githubusercontent.com/sickill/vim-monokai/master/colors/monokai.vim
7、安装Clang
sudo yum install cmake -y
cd ~/.vim/plugin/YouCompleteMe
./install.py --clang-completer
8、测试
9、error
(1)YouCompleteMe unavailable: No module named builtins
go to YCM folder (typically ~/.vim/bundle/YouCompleteMe
), and run the following command:
git submodule update --init --recursive
(2)The ycmd server SHUT DOWN (restart with
':YcmRestartServer'). Unexpected exit code 1. #2831
run:::::: git submodule update --init --recursive