Skip to content

Instantly share code, notes, and snippets.

@innyso
Last active April 11, 2020 12:18
Show Gist options
  • Save innyso/541215ec4449f1959cff63f853da8266 to your computer and use it in GitHub Desktop.
Save innyso/541215ec4449f1959cff63f853da8266 to your computer and use it in GitHub Desktop.
#vim #golang

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
  1. 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

  2. Need to get latest vim with lua support brew install vim --with-lua --override-system-vim

  3. use which vim to check whether you are using the system vim or the new brew vim, the one you should be expecting is from /usr/local/bin not /usr/bin

  4. I found the --override-system-vim didnt work for me so I updated my PATH variable to make sure /usr/local/bin is before /usr/bin

  5. install gotags brew install gotags

  6. 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
  1. Install all go binaries by running :GoInstallBinaries in vim

  2. Install vim-go-ide by running sh ~/.vim_go_runtime/bin/install

  3. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment