Skip to content

Commit

Permalink
Accept multiple arguments for go#cmd#Vet
Browse files Browse the repository at this point in the history
This allows the use of useful experimental flags under `go tool vet`.
  • Loading branch information
guns committed Jul 24, 2015
1 parent 32846c4 commit b60ac3b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions autoload/go/cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,14 @@ endfunction

" Vet calls "go vet' on the current directory. Any warnings are populated in
" the quickfix window
function! go#cmd#Vet(bang)
function! go#cmd#Vet(bang, ...)
call go#cmd#autowrite()
echon "vim-go: " | echohl Identifier | echon "calling vet..." | echohl None
let out = go#tool#ExecuteInDir('go vet')
if a:0 == 0
let out = go#tool#ExecuteInDir('go vet')
else
let out = go#tool#ExecuteInDir('go tool vet ' . go#util#Shelljoin(a:000))
endif
if v:shell_error
call go#tool#ShowErrors(out)
else
Expand Down
6 changes: 5 additions & 1 deletion doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,18 @@ COMMANDS *go-commands*
'xterm-clipboard' otherwise it's get yanked into the `""` register.

*:GoVet*
:GoVet[!]
:GoVet[!] [options]

Run `go vet` for the directory under your current file. Vet examines Go
source code and reports suspicious constructs, such as Printf calls whose
arguments do not align with the format string. Vet uses heuristics that do not
guarantee all reports are genuine problems, but it can find errors not caught
by the compilers.

You may optionally pass any valid go tool vet flags/options. In this case,
`go tool vet` is run in place of `go vet`. For a full list please see
`go tool vet -h`.

If [!] is not given the first error is jumped to.

*:GoDef*
Expand Down
2 changes: 1 addition & 1 deletion ftplugin/go/commands.vim
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ command! -nargs=* -bang GoTest call go#cmd#Test(<bang>0, 0, <f-args>)
command! -nargs=* -bang GoTestFunc call go#cmd#TestFunc(<bang>0, <f-args>)
command! -nargs=* -bang GoTestCompile call go#cmd#Test(<bang>0, 1, <f-args>)
command! -nargs=* -bang GoCoverage call go#cmd#Coverage(<bang>0, <f-args>)
command! -nargs=0 -bang GoVet call go#cmd#Vet(<bang>0)
command! -nargs=* -bang GoVet call go#cmd#Vet(<bang>0, <f-args>)

" -- play
command! -nargs=0 -range=% GoPlay call go#play#Share(<count>, <line1>, <line2>)
Expand Down

0 comments on commit b60ac3b

Please sign in to comment.