Projectionist for Go

I've been using Vim exclusively for all of my Go development work for the past year or so and over that time I've slowly been customizing my setup.

There are a number of essential plugins, including Vim-go and YouCompleteMe, but after recently working on a Rails project I encountered Vim-rails which includes some useful commands to jump around the project such as:

  • :Econtroller users
  • :Emodel thing
  • :Eview blah

Along with setting up alternates for jumping between source files and test files etc...

I wanted the same for my Go projects and luckily Tim Pope split out the functionality into a standalone Vim plugin called Vim-projectionist that lets you do just that.

After some fudging around with the project specific option I managed to get a global config that you can drop into your .vimrc:

let g:projectionist_heuristics = {  
            \ '*.go': {
            \   '*.go': {
            \       'alternate': '{}_test.go',
            \       'type': 'source'
            \   },
            \   '*_test.go': {
            \       'alternate': '{}.go',
            \       'type': 'test'
            \   },
            \ }}

It's fairly minimal with support only for the :A command to jump between the source and test file, but it can work in conjunction with a .projections.json file to add project specific configs as well.