CentOS 8 搭建Vim golang环境
Vim搭建Golang IDE
1. Vundle安装
Vundle是vim的插件管理工具,用它可以自动管理安装后面用到的插件,从GitHub安装
cd
mkdir .vim/bundle
cd .vim/bundle
git clone https://github.com/Valloric/YouCompleteMe.git
安装完成后修改~/.vimrc启用
" .vimrc
" vundle
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
call vundle#end()
2. 安装vim插件
插件管理软件安装好了,接下来安装需要的插件:
- vim-go: https://github.com/fatih/vim-go
- YouCompleteMe: https://github.com/Valloric/YouCompleteMe
- Tagbar: https://github.com/majutsushi/tagbar
- NERDTree: https://github.com/scrooloose/nerdtree
使用vundle自动安装,修改.vimrc
" vundle
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'fatih/vim-go'
Plugin 'Valloric/YouCompleteMe'
Plugin 'Tagbar'
Plugin 'scrooloose/nerdtree'
call vundle#end()
保存,然后vim打开任意文件,输入:PluginInstall
自动开始安装
这个过程异常漫长,特别是YouCompleteMe,可以手动安装
cd ~/.vim/bundle
git clone https://github.com/fatih/vim-go
git clone https://github.com/majutsushi/tagbar
git clone https://github.com/scrooloose/nerdtree
git clone https://github.com/Valloric/YouCompleteMe
cd YouCompleteMe
git submodule update --init --recursive
YouCompleteMe递归安装很多依赖包,需很长时间,并且下载完成后还需要编译安装,见下一节
Tagbar需要ctags/gotags支持
yum install ctags -y
go get -u github.com/jstemmer/gotags