The aim of this is to setup vim for golang development on my mac. Things that we are looking for is:
- autocomplete especially for buildin method and variables in the same file
- shortcut for running test and building code
- method listing
-
Make sure I have xcode commandline installed so that I can install the latest vim using brew in the next step without getting some sort of ruby error
xcode-select --install -
Need to get latest vim with lua support
brew install vim --with-lua --override-system-vim -
use
which vimto check whether you are using the system vim or the new brew vim, the one you should be expecting is from/usr/local/binnot/usr/bin -
I found the
--override-system-vimdidnt work for me so I updated my PATH variable to make sure/usr/local/binis before/usr/bin -
install gotags
brew install gotags -
get vim-go, neocomplete, vim-go-ide and tagbar plugin
git clone https://github.com/fatih/vim-go.git ~/.vim/bundle
git clone https://github.com/Shougo/neocomplete.vim.git ~/.vim/bundle
git clone https://github.com/farazdagi/vim-go-ide.git ~/.vim/bundle
git clone https://github.com/majutsushi/tagbar.git ~/.vim/bundle
-
Install all go binaries by running
:GoInstallBinariesin vim -
Install vim-go-ide by running
sh ~/.vim_go_runtime/bin/install -
Add the following to ~/.zshrc to overwrite vi command and create vim-go-ide alias
alias vimgo='export GOPATH=`pwd` && vim -u ~/.vimrc.go'
alias vi=vim