開始決定丟棄鼠標,因此準備用vim了。git
那麼在vim裏面如何搭建golang環境呢?github
git盛行之下,搭建vim環境是如此簡單。golang
並且vim搭建好了以後,基本上跟IDE沒有差異。vim
高亮、自動補全、自動格式化、查看定義跳轉、語法檢測等等等等, 簡直是不要不要的:oracle
gocode
gofmt
on save, which keeps cursor position and doesn't break your undo history:GoDef
:GoDoc
inside Vim or open it in browser:GoImport
or plug it into autosave:GoBuild
, install it with :GoInstall
or test them with :GoTest
(also supports running single tests via :GoTestFunc
):GoRun
GOPATH
detection based on the directory structure (i.e. gb
projects, godep
vendored projects)GOPATH
with :GoPath
:GoCoverage
gometalinter
with :GoMetaLinter
, which invokes all possible linters (golint, vet, errcheck, deadcode, etc..) and shows the warnings/errors:GoLint
:GoVet
to catch static errors:GoImplements
, :GoCallees
, and :GoReferrers
:GoRename
:GoErrCheck
ultisnips
or neosnippet
:GoPlay
gotags
a function
or inner function
list.:GoRun
and other go commands in their own new terminal. (beta):GoAlternate
安裝起來也很是方便,只要一下三行代碼:async
#下載安裝
git clone git@github.com:farazdagi/vim-go-ide.git ~/.vim_go_runtime
sh ~/.vim_go_runtime/bin/install
#運行
vim -u ~/.vimrc.go
PS:ide
a)這裏要求vim 要開啓lua : 函數
brew install vim --with-lua --override-system-vim
b)若是須要類解析,須要轉ctagui
--------------------lua
2016-10-20補充
若是把go升級到go1.7,這裏的函數 auto-complete 會顯示PANIC不能顯示任何的系統庫對應的函數和自定義的函數
這裏須要作一件事情,能夠恢復
ps aux | grep gocode #存在就幹掉 killall gocode #重啓 gocode
或者採用如下方式
gocode close && go get -u github.com/nsf/gocode
參考這裏:https://github.com/fatih/vim-go/issues/1015
---------------------
原文:http://farazdagi.com/blog/2015/vim-as-golang-ide/
效果以下: