Monday, September 12, 2016

Vim + Go + Mac

There's a lot of notes written for getting Vim + Go up and running, but a lot of the notes assume you're already in modern Vim-land.  Here's what I did to get up and going from scratch.

0.  Start off with a totally clean vim configuration.

Save off your current files/setting if they're important to you.

    cd $HOME
    rm -rf .vim .vimrc .viminfo

1.  Install a vim with lua support.

I think the easiest way to do this is to install the latest macvim from Homebrew.  If you're a developer on Mac,  Homebrew is well worth looking into.

    brew install macvim --with-cscope --with-lua --override-system-vim
    brew linkapps macvim
    brew install vim --with-lua --override-system-vim

2.  Install Vundle

There's a couple of Vim package managers.  I don't know enough about Vim package management to recommend one over another, but Vundle seems to be pretty popular.

    git clone ~/.vim/bundle/Vundle.vim

Here's the minimal .vimrc needed to get bootstrapped.

    set nocompatible              
    filetype off                  

    set rtp+=~/.vim/bundle/Vundle.vim

    call vundle#begin()
    Plugin 'VundleVim/Vundle.vim'
    "Plugin 'Valloric/YouCompleteMe'    reserve for step 3 below
    "Plugin 'fatih/vim-go'              <------- font="" nbsp="">reserve for step 4 below
    call vundle#end()            

    filetype plugin indent on    

Restart vim and install the plugins with the command


3. Install YouCompleteMe

This require you install XCode from Apple.  Start off by installing cmake.

    brew install cmake

Install YouCompleteMe and pull in submodules.

    cd ~/.vim/bundle
    git clone
    cd ~/.vim/bundle/YouCompleteMe
    git submodule update --init --recursive

Build YouCompleteMe

    cd ~/.vim/bundle/YouCompleteMe
    ./ --gocode-completer

Make sure ~/.vimrc has the line

Plugin 'Valloric/YouCompleteMe'

Restart vim and install the plugin as we did above


4. Install Vim-Go

Download the latest release from and untar it.

    cd /tmp
    curl -s | tar xf -

And move all the directories into .vim.  It seems there should be and easier way to do this... ping me if you know what it is!

    (cd /tmp/vim-go-1.8; tar cf - autoload compiler doc \
       ftdetect ftplugin gosnippets indent plugin scripts syntax t templates) |
      (cd ~/.vim; tar xf -)

Then add to .vimrc

    Plugin 'fatih/vim-go'

Restart vim and run


No comments: