vim-go
使用Vundle.vim安装,在.vimrc
相应位置添加如下一句:
Plugin 'fatih/vim-go'
然后:PluginInstall
,这样就装好了。
vim-go
提供了很多功能,不如称它为一个“collection”,下面装“collection”里面的东西::GoInstallBinaries
。
如果你没有问题地畅通无阻地看到了“Finished”,除非你不在大陆,要么就是“身在曹营”,IP不知道跑哪去了【你懂的】。
一下操作是针对没有“梯子”的朋友们:
:GoInstallBinaries
总共会安装这么几样东西,可以在.vim/bundle/vim-go/plugin/go.vim
中看到:
let s:packages = {
\ 'asmfmt': ['github.com/klauspost/asmfmt/cmd/asmfmt'],
\ 'dlv': ['github.com/go-delve/delve/cmd/dlv'],
\ 'errcheck': ['github.com/kisielk/errcheck'],
\ 'fillstruct': ['github.com/davidrjenni/reftools/cmd/fillstruct'],
\ 'gocode': ['github.com/mdempsky/gocode', {'windows': ['-ldflags', '-H=windowsgui']}],
\ 'gocode-gomod': ['github.com/stamblerre/gocode'],
\ 'godef': ['github.com/rogpeppe/godef'],
\ 'gogetdoc': ['github.com/zmb3/gogetdoc'],
\ 'goimports': ['golang.org/x/tools/cmd/goimports'],
\ 'golint': ['golang.org/x/lint/golint'],
\ 'gopls': ['golang.org/x/tools/cmd/gopls'],
\ 'gometalinter': ['github.com/alecthomas/gometalinter'],
\ 'gomodifytags': ['github.com/fatih/gomodifytags'],
\ 'gorename': ['golang.org/x/tools/cmd/gorename'],
\ 'gotags': ['github.com/jstemmer/gotags'],
\ 'guru': ['golang.org/x/tools/cmd/guru'],
\ 'impl': ['github.com/josharian/impl'],
\ 'keyify': ['honnef.co/go/tools/cmd/keyify'],
\ 'motion': ['github.com/fatih/motion'],
\ 'iferr': ['github.com/koron/iferr'],
\ }
其中,只要是和golang.org
有关系的,你都会安装不成功。甚至gocode
等你也不能成功安装,因为依赖golang.org/x/tools
中的东西。应对这种情况,Google当然不会放弃广大的中国大陆程序员啦,在github.com/golang里就能找到mirror
。
$GOPATH/src/
建立路径golang.org/x/
:cd $GOPATH/src
mkdir -p golang.org/x
cd golang.org/x
tools
clone到当前路径:git clone https://github.com/golang/tools.git
build
并install
需要的包,以goimports
为例(guru
、gopls
、gorename
同):cd tools/cmd/goimports
go buiild
go install
golint
的mirror,安装方法同上。keyify
的mirror,需要在src/
建立honnef.co/go/
,然后clone,并且要该名字,改为tools
。:GoInstallBinaries
装吧。