All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Joshua Rubin <joshua@rubixconsulting.com>, Ben Reedy <https://github.com/breed808>,
2 " Jeff Willette <jrwillette88@gmail.com>
3 " Description: go build for Go files
4 " inspired by work from dzhou121 <dzhou121@gmail.com>
6 call ale#Set('go_go_executable', 'go')
7 call ale#Set('go_gobuild_options', '')
9 function! ale_linters#go#gobuild#GetMatches(lines) abort
10 " Matches patterns like the following:
12 " file.go:27: missing argument for Printf("%s"): format reads arg 2, have only 1 args
13 " file.go:53:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
14 " file.go:5:2: expected declaration, found 'STRING' "log"
15 " go test returns relative paths so use tail of filename as part of pattern matcher
16 let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:? (.+)$'
18 return ale#util#GetMatches(a:lines, l:pattern)
21 function! ale_linters#go#gobuild#Handler(buffer, lines) abort
22 let l:dir = expand('#' . a:buffer . ':p:h')
25 for l:match in ale_linters#go#gobuild#GetMatches(a:lines)
27 \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
28 \ 'lnum': l:match[2] + 0,
29 \ 'col': l:match[3] + 0,
38 call ale#linter#Define('go', {
40 \ 'aliases': ['go build'],
41 \ 'executable': {b -> ale#Var(b, 'go_go_executable')},
45 \ . ale#Escape(ale#Var(b, 'go_go_executable')) . ' test'
46 \ . ale#Pad(ale#Var(b, 'go_gobuild_options'))
47 \ . ' -c -o /dev/null ./'
49 \ 'output_stream': 'stderr',
50 \ 'callback': 'ale_linters#go#gobuild#Handler',