Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autoload/go/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ endfunction
function! go#config#MetalinterEnabled() abort
let l:default = []
if get(g:, 'go_metalinter_command', s:default_metalinter) == 'golangci-lint'
let l:default = ['vet', 'revive', 'errcheck']
let l:default = ['govet', 'revive', 'errcheck']
endif

return get(g:, 'go_metalinter_enabled', l:default)
Expand Down
23 changes: 17 additions & 6 deletions autoload/go/lint.vim
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ function! go#lint#Gometa(bang, autosave, ...) abort
" Parse and populate our location list

if a:autosave
call s:metalinterautosavecomplete(l:metalinter, fnamemodify(expand('%:p'), ':.'), 0, 1, l:messages)
if l:metalinter == 'golangci-lint'
call s:metalinterautosavecomplete(l:metalinter, expand('%:p'), 0, 1, l:messages)
elseif l:metalinter == 'staticcheck'
call s:metalinterautosavecomplete(l:metalinter, fnamemodify(expand('%:p'), ':.'), 0, 1, l:messages)
endif
endif
call go#list#ParseFormat(l:listtype, l:errformat, l:messages, l:for, s:preserveerrors(a:autosave, l:listtype))

Expand Down Expand Up @@ -396,7 +400,11 @@ function! s:lint_job(metalinter, args, bang, autosave)
if a:autosave
let l:opts.for = 'GoMetaLinterAutoSave'
" s:metalinterautosavecomplete is needed for staticcheck and golangci-lint
let l:opts.complete = funcref('s:metalinterautosavecomplete', [a:metalinter, expand('%:p:t')])
if a:metalinter == 'golangci-lint'
let l:opts.complete = funcref('s:metalinterautosavecomplete', [a:metalinter, expand('%:p')])
elseif a:metalinter == 'staticcheck'
let l:opts.complete = funcref('s:metalinterautosavecomplete', [a:metalinter, expand('%:p:t')])
endif
let l:opts.preserveerrors = funcref('s:preserveerrors', [a:autosave])
endif

Expand All @@ -423,15 +431,17 @@ endfunction
function! s:golangcilintcmd(bin_path, haslinter)
let l:cmd = [a:bin_path]
let l:cmd += ["run"]
let l:cmd += ["--print-issued-lines=false"]
let l:cmd += ["--show-stats=false"]
let l:cmd += ["--output.text.print-issued-lines=false"]
let l:cmd += ['--build-tags', go#config#BuildTags()]
let l:cmd += ['--path-mode', 'abs']
" do not use the default exclude patterns, because doing so causes golint
" problems about missing doc strings to be ignored and other things that
" golint identifies.
let l:cmd += ["--exclude-use-default=false"]
"let l:cmd += ["--exclude-use-default=false"]

if a:haslinter
let l:cmd += ["--disable-all"]
let l:cmd += ["--default=none"]
endif

return l:cmd
Expand All @@ -446,6 +456,8 @@ function! s:metalinterautosavecomplete(metalinter, filepath, job, exit_code, mes
return
endif

let l:pathRE = printf('^%s:', a:filepath)

let l:idx = 0
for l:item in a:messages
" leave in any messages that report errors about a:filepath or that report
Expand All @@ -458,7 +470,6 @@ function! s:metalinterautosavecomplete(metalinter, filepath, job, exit_code, mes
"
" golangci-lint may provide a relative path to the file, so allow that,
" too.
let l:pathRE = printf('^\%%(\.%s\)\?%s', go#util#PathSep(), a:filepath)
if (l:item =~# l:pathRE && l:item !~# l:pathRE . ':\d\+: : # ') || (a:metalinter == 'golangci-lint' && l:item =~# '^level=')
let l:idx += 1
continue
Expand Down
8 changes: 4 additions & 4 deletions doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ window. The list to use can be set using |'g:go_list_type_commands'|.
*'g:go_metalinter_autosave_enabled'*

Specifies the enabled linters for auto |:GoMetaLinter| on save. When the
metalinter is `golangci-lint`, if any are enabled, `--disable-all` will be
metalinter is `golangci-lint`, if any are enabled, `--default=none` will be
sent to the metalinter.

When `g:go_metalinter_command` is set to `staticcheck`, the default value is
Expand All @@ -1522,12 +1522,12 @@ an empty list; `staticcheck`'s `-checks` flag will not be used.

When `g:go_metalinter_command is set to `golangci-lint`, the default value is
>
let g:go_metalinter_autosave_enabled = ['vet', 'revive']
let g:go_metalinter_autosave_enabled = ['govet', 'revive']
<
*'g:go_metalinter_enabled'*

Specifies the linters to enable for the |:GoMetaLinter| command. For
`golangci-lint`, if any are enabled, `--disable-all` will be passed to the
`golangci-lint`, if any are enabled, `--default=none` will be passed to the
metalinter.

When `g:go_metalinter_command` is set to `staticcheck`, the default value is
Expand All @@ -1539,7 +1539,7 @@ an empty list; `staticcheck`'s `-checks` flag will not be used.
When `g:go_metalinter_command` is set to `golangci-lint`, the default value
is
>
let g:go_metalinter_enabled = ['vet', 'revive', 'errcheck']
let g:go_metalinter_enabled = ['govet', 'revive', 'errcheck']
<
*'g:go_metalinter_command'*

Expand Down
2 changes: 1 addition & 1 deletion plugin/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let s:packages = {
\ 'goimports': ['golang.org/x/tools/cmd/goimports@master'],
\ 'revive': ['github.com/mgechev/revive@latest'],
\ 'gopls': ['golang.org/x/tools/gopls@latest', {}, {'after': function('go#lsp#Restart', [])}],
\ 'golangci-lint': ['github.com/golangci/golangci-lint/cmd/golangci-lint@latest'],
\ 'golangci-lint': ['github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest'],
\ 'staticcheck': ['honnef.co/go/tools/cmd/staticcheck@latest'],
\ 'gomodifytags': ['github.com/fatih/gomodifytags@latest'],
\ 'gotags': ['github.com/jstemmer/gotags@master'],
Expand Down
Loading