标签:vim-go vim golang ycm vundle
1 简介
上一篇博客我们介绍了Golang的安装、编译、运行,本篇博客我们介绍如何设置面向Golang的vim开发环境。原生的vim无法自行识别golang关键字,开发环境如同编辑普通文本文件,无法高亮显示,更不要说自动补全等功能。为此,我们需要在vim中加入面向golang的插件vim-go。同时,根据vim-go的安装引导,我们还需要安装YouCompleteMe(YCM)。
2 安装Vundle
Vundle的git页面 https://github.com/VundleVim/Vundle.vim
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
3 安装vim-go
vim-go的git页面 https://github.com/fatih/vim-go
git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go
4 安装YCM
YCM的git页面 https://github.com/Valloric/YouCompleteMe
4.1 前提条件
vim版本7.3.584以上
安装依赖
sudo apt-get install build-essential cmake sudo apt-get install python-dev
4.2 git clone
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
4.3 编译安装
进入~/.vim/bundle/YouCompleteMe目录,执行
git submoduleupdate --init --recursive ./install.py –clang-completer –gocode-completer
这两条命令执行时间较长,尤其第一条,可以并行做点别的。
5 配置
编辑~/.vimrc
"------------- "Vundle "https://github.com/gmarik/Vundle.vim "------------- setnocompatible " beiMproved, required filetypeoff " required " set theruntime path to include Vundle and initialize setrtp+=~/.vim/bundle/Vundle.vim callvundle#begin() "alternatively, pass a path where Vundle should install plugins "callvundle#begin(‘~/some/path/here‘) " letVundle manage Vundle, required Plugin‘gmarik/Vundle.vim‘ " Thefollowing are examples of different formats supported. " KeepPlugin commands between vundle#begin/end. " pluginon GitHub repo ""Plugin‘tpope/vim-fugitive‘ " pluginfrom http://vim-scripts.org/vim/scripts.html ""Plugin‘L9‘ " Gitplugin not hosted on GitHub ""Plugin‘git://git.wincent.com/command-t.git‘ " gitrepos on your local machine (i.e. when working on your own plugin) ""Plugin‘file:///home/gmarik/path/to/plugin‘ " Thesparkup vim script is in a subdirectory of this repo called vim. " Passthe path to set the runtimepath properly. ""Plugin‘rstacruz/sparkup‘, {‘rtp‘: ‘vim/‘} " Avoid aname conflict with L9 ""Plugin‘user/L9‘, {‘name‘: ‘newL9‘} " InstallVim-go Plugin‘fatih/vim-go‘ " Install YCM Plugin‘Valloric/YouCompleteMe‘ " All ofyour Plugins must be added before the following line callvundle#end() "required filetypeplugin indent on " required " Toignore plugin indent changes, instead use: "filetypeplugin on " " Briefhelp ":PluginList - lists configuredplugins ":PluginInstall - installs plugins;append `!` to update or just :PluginUpdate ":PluginSearch foo - searches for foo; append `!` to refresh local cache ":PluginClean - confirms removal ofunused plugins; append `!` to auto-approve removal " " see :hvundle for more details or wiki for FAQ " Putyour non-Plugin stuff after this line set smarttab setshiftwidth=4 set tabstop=4 setsofttabstop=4 set expandtab autocmdFileType go set expandtab
6 参考
https://github.com/gmarik/Vundle.vim
http://studygolang.com/articles/2927
https://github.com/fatih/vim-go
http://howiefh.github.io/2015/05/22/vim-install-youcompleteme-plugin/
https://github.com/Valloric/YouCompleteMe
本文出自 “说话的白菜” 博客,谢绝转载!
标签:vim-go vim golang ycm vundle
原文地址:http://speakingbaicai.blog.51cto.com/5667326/1701457