1 簡介
html
上一篇博客咱們介紹了Golang的安裝、編譯、運行,本篇博客咱們介紹如何設置面向Golang的vim開發環境。原生的vim沒法自行識別golang關鍵字,開發環境如同編輯普通文本文件,沒法高亮顯示,更不要說自動補全等功能。爲此,咱們須要在vim中加入面向golang的插件vim-go。同時,根據vim-go的安裝引導,咱們還須要安裝YouCompleteMe(YCM)。python
2 安裝Vundlegit
Vundle的git頁面 https://github.com/VundleVim/Vundle.vimgithub
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
3 安裝vim-go
golang
vim-go的git頁面 https://github.com/fatih/vim-go vim
git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go
4 安裝YCMbash
YCM的git頁面 https://github.com/Valloric/YouCompleteMeapp
4.1 前提條件
ide
vim版本7.3.584以上ui
安裝依賴
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/