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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With