Setup vim for Development with Go, and JS

Description

Notes from setting up vim with a handful of plugins for Go, Javascript development.

Context

I was a long time emacs user that migrated to Sublime Text (ST) Almost 3 years ago. I started with ST2 and changed to ST3 when I stopped using a Mac as my primary OS. I am very happy with ST. It is well worth the $70 (US). However, development is excruciatingly slow and there is zero communication about its future. The ST3 beta came out in January 2013. 18 months later we are still in beta. I suppose I could — and may — go on using the beta indefinitely. But what fun would that be.
There are quite a few folks whom I respect which are from the other side of the editor wars — vim. I have long had it on my plate to learn more vim. This is an early step in that direction.
Having never used vim as my editor I am starting from scratch; without
~/.vimrc even. That said I am not starting from scratch on my workstation so these notes may miss installing dependencies which already present on my system.

Solution

Install a handful of plugins with a plugin manager to make developing Go more efficient. The plugins installed are:

  1. Vundle
  2. go-vim
  3. YouCompleteMe
  4. tagbar
  5. vim-commentary
  6. delimitMate
  7. syntastic
  8. vim-javascript-syntax
  9. Vim Javascript
  10. vim indent guides
  11. tern for vim

Using these plugins together with an otherwise vanilla vim provides code highlighting, completion, and hinting in Go, JavaScript, and Python. It also provides Syntax linting for Go and JavaScript. I stil need to find a good Python linter.

Vundle

Vundle is a plugin manager for vim. It downloads, installs, manages and updates vim plugin packages. NB: Vundle requires vim 7.4.
First we need to create a place for vim bundles or plugins, checkout Vundle and generate a vimrc.

$ mkdir -p ~/.vim/bundle # create dir
$ git clone https://github.com/gmarik/Vundle.vim.git # clone vundle

Then we need a .vimrc file setup as outlined in the Vundle README under bullet 3, as of this writing. A stripped down version might look like this:

set nocompatible    " be iMproved -required
filetype off               " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

" " Go
Plugin 'fatih/vim-go'

" " General
Plugin 'Valloric/YouCompleteMe'
Plugin 'majutsushi/tagbar'
Plugin 'tpope/vim-commentary'
Plugin 'Raimondi/delimitMate'
Plugin 'scrooloose/syntastic'

" " Javascript
Plugin 'jelera/vim-javascript-syntax'
Plugin 'pangloss/vim-javascript'
Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'marijnh/tern_for_vim'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
" Put your non-Plugin stuff after this line

Once the rc file is setup you need to let Vundle install the rest of the plugins for you. You can do that by calling vim with an argument: vim +BundleInstall. Alternatively you can start it and call PluginInstall:

start vim
:PluginInstall

go-vim

go-vim is a “Full featured” plugin for Go development. It is essentially a meta-plugin that installs go-code, go-imports and sets up a bunch of useful defaults. See the README at the above link for more information.

YouCompleteMe

YouCompleteMe is a fuzzy search code completion engine for Vim. It requires a coulple extra steps to compile and integrate completely.

$ cd ~/.vim/bundle/YouCompleteMe
$ # ensure the requirements are installed
$ sudo apt-get install cmake python-dev build-essential # Present on OSX if XCode is installed.
$ ./install.sh --clang-completer

tagbar

tagbar is a plugin that displays tags in a window, ordered by class, function, etc…

vim-commentary

vim-commentary is a plugin to make un/commenting code (out) easier and more efficient in Vim.

delimitMate

delimitMate is a plugin that provides something like electric-pair-mode in emacs.

syntastic

syntastic is a plugin that provides a plugpoin to run external syntax checkers on code within Vim.

vim-javascript-syntax

vim-javascript-syntax adds enhanced JS syntax to Vim

vim-javascript

Vim Javascript fixes the other JS syntax bits or something…

Vim Indent Guides

vim indent guides is a plugin that visually displays indent guides…

Tern for Vim

Tern for Vim is a plugin that provides Tern-based JavaScript editing support.
Make sure you have node.js and npm installed (Tern is a JavaScript program), and install the tern server by running

npm install 

in the bundle/tern_for_vim directory.

To Explore

There are other plugin managers for vim which is left to the reader to compare if they desire. Similar setups are available in emacs and SublimeText — this is also left as an exercise for the reader.
There are still a few items left that I would like to explore.

  1. Python – There are still a few things about Python that I need to get setup in vim. PEP8 linting is one major one. Possibilities to explore?
  2. angular – We are doing a lot of angular work, so it would be nice if I could get a little more editor love for it. Not a show stopper…
  3. tab settings – I am unclear on some of the tab settings. I think I have it set up in a way that makes me happy, but I am not positive.
  4. Lastly, I need to get my head around modal editing. I still have trouble remembering the syntax for doing most anything other than typing. That will come with time and use though.

Wish me luck! Constructive feedback and suggestions welcome.