Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim makeprg and errorformat for Go

Tags:

vim

go

I would like to be able to build and run Go code from within vim with access to quickfix window if there are compilation errors.

To achieve something close to this with Java I added the following to my .vimrc:

autocmd Filetype java set makeprg=ant\ -find\ build.xml
autocmd Filetype java set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#

I have the following currently for Go in my .vimrc:

autocmd Filetype go set makeprg=go\ run

What can I have to make :make (or :make %) act like it would for a good 'ol C program with pretty error reporting and output below the buffer?

like image 701
lyallcooper Avatar asked Jun 14 '12 21:06

lyallcooper


1 Answers

For cases where your current working directory consists of a single program or library, the following works fine with Vim:

autocmd Filetype go set makeprg=go\ build

For cases where there is just one file you want to compile, I override this with:

:set makeprg=go\ build\ hello.go

More can be found at jnwhiteh's vim-golang.

like image 157
swdunlop Avatar answered Sep 28 '22 13:09

swdunlop