VIM配置Golang开发环境

直接使用vim-as-golang-ide来配置非常简单,具体操作如下。
http://farazdagi.com/blog/2015/vim-as-golang-ide/
对应Github地址:https://github.com/farazdagi/vim-go-ide
然后执行vim -u ~/.vimrc.go即可,如果嫌麻烦,可以设置alias.

1
alias vimgo='vim -u ~/.vimrc.go'

vim-as-golang-ide实际上用到的仍然是vim-go. vim-as-golang-ide的好处时不破坏系统vim的设置。
vim-go: https://github.com/fatih/vim-go

执行完vim -u ~/.vimrc.go出现如下错误。

1
2
3
CSApprox skipped; terminal only has 8 colors, not 88/256
Try checking :help csapprox-terminal for workarounds
请按 ENTER 或其它命令继续

可在~/.vimrc.go中进行如下设置。

1
set t_Co=256

在进行:GoInstallBinaries之前需要临时设置$GOBIN环境变量,以便vim-go需要的binary放在/usr/local/go/bin下。

1
export GOBIN=$GOROOT/bin

Please be sure all necessary binaries are installed (such as gocode, godef, goimports, etc.). You can easily install them with the included :GoInstallBinaries command. If invoked, all necessary binaries will be automatically downloaded and installed to your $GOBIN environment (if not set it will use $GOPATH/bin). Note that this command requires git for fetching the individual Go packages. Additionally, use :GoUpdateBinaries to update the installed binaries.
https://github.com/fatih/vim-go

vim-go依赖于很多其他binary,需自备梯子。
国内有个Go Package Manager: https://gopm.io/ 可以下载到被墙的binaries.