Vim makeprg and errorformat for Go

I would like to be able to create and run Go code from vim with access to the 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 for Go in my .vimrc:

 autocmd Filetype go set makeprg=go\ run 

What can I do to do :make (or :make % ), as it would be for a good ol c program with pretty error reporting and output below the buffer?

+6
source share
1 answer

In cases where your current working directory consists of one program or library, the following is done in Vim:

 autocmd Filetype go set makeprg=go\ build 

In cases where there is only one file that you want to compile, I override this:

 :set makeprg=go\ build\ hello.go 

More can be found in jnwhiteh vim-golang .

+3
source

Source: https://habr.com/ru/post/918132/


All Articles