Skip to content

Commit 80eec06

Browse files
authored
Merge pull request #3710 from bhcleek/golangci-lint/v2
lint: update to golangci-lint/v2
2 parents 59e208d + 4dc5780 commit 80eec06

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

autoload/go/config.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ endfunction
262262
function! go#config#MetalinterEnabled() abort
263263
let l:default = []
264264
if get(g:, 'go_metalinter_command', s:default_metalinter) == 'golangci-lint'
265-
let l:default = ['vet', 'revive', 'errcheck']
265+
let l:default = ['govet', 'revive', 'errcheck']
266266
endif
267267

268268
return get(g:, 'go_metalinter_enabled', l:default)

autoload/go/lint.vim

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ function! go#lint#Gometa(bang, autosave, ...) abort
110110
" Parse and populate our location list
111111

112112
if a:autosave
113-
call s:metalinterautosavecomplete(l:metalinter, fnamemodify(expand('%:p'), ':.'), 0, 1, l:messages)
113+
if l:metalinter == 'golangci-lint'
114+
call s:metalinterautosavecomplete(l:metalinter, expand('%:p'), 0, 1, l:messages)
115+
elseif l:metalinter == 'staticcheck'
116+
call s:metalinterautosavecomplete(l:metalinter, fnamemodify(expand('%:p'), ':.'), 0, 1, l:messages)
117+
endif
114118
endif
115119
call go#list#ParseFormat(l:listtype, l:errformat, l:messages, l:for, s:preserveerrors(a:autosave, l:listtype))
116120

@@ -396,7 +400,11 @@ function! s:lint_job(metalinter, args, bang, autosave)
396400
if a:autosave
397401
let l:opts.for = 'GoMetaLinterAutoSave'
398402
" s:metalinterautosavecomplete is needed for staticcheck and golangci-lint
399-
let l:opts.complete = funcref('s:metalinterautosavecomplete', [a:metalinter, expand('%:p:t')])
403+
if a:metalinter == 'golangci-lint'
404+
let l:opts.complete = funcref('s:metalinterautosavecomplete', [a:metalinter, expand('%:p')])
405+
elseif a:metalinter == 'staticcheck'
406+
let l:opts.complete = funcref('s:metalinterautosavecomplete', [a:metalinter, expand('%:p:t')])
407+
endif
400408
let l:opts.preserveerrors = funcref('s:preserveerrors', [a:autosave])
401409
endif
402410

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

433443
if a:haslinter
434-
let l:cmd += ["--disable-all"]
444+
let l:cmd += ["--default=none"]
435445
endif
436446

437447
return l:cmd
@@ -446,6 +456,8 @@ function! s:metalinterautosavecomplete(metalinter, filepath, job, exit_code, mes
446456
return
447457
endif
448458

459+
let l:pathRE = printf('^%s:', a:filepath)
460+
449461
let l:idx = 0
450462
for l:item in a:messages
451463
" leave in any messages that report errors about a:filepath or that report
@@ -458,7 +470,6 @@ function! s:metalinterautosavecomplete(metalinter, filepath, job, exit_code, mes
458470
"
459471
" golangci-lint may provide a relative path to the file, so allow that,
460472
" too.
461-
let l:pathRE = printf('^\%%(\.%s\)\?%s', go#util#PathSep(), a:filepath)
462473
if (l:item =~# l:pathRE && l:item !~# l:pathRE . ':\d\+: : # ') || (a:metalinter == 'golangci-lint' && l:item =~# '^level=')
463474
let l:idx += 1
464475
continue

doc/vim-go.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ window. The list to use can be set using |'g:go_list_type_commands'|.
15111511
*'g:go_metalinter_autosave_enabled'*
15121512

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

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

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

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

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

plugin/go.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let s:packages = {
4848
\ 'goimports': ['golang.org/x/tools/cmd/goimports@master'],
4949
\ 'revive': ['github.com/mgechev/revive@latest'],
5050
\ 'gopls': ['golang.org/x/tools/gopls@latest', {}, {'after': function('go#lsp#Restart', [])}],
51-
\ 'golangci-lint': ['github.com/golangci/golangci-lint/cmd/golangci-lint@latest'],
51+
\ 'golangci-lint': ['github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest'],
5252
\ 'staticcheck': ['honnef.co/go/tools/cmd/staticcheck@latest'],
5353
\ 'gomodifytags': ['github.com/fatih/gomodifytags@latest'],
5454
\ 'gotags': ['github.com/jstemmer/gotags@master'],

0 commit comments

Comments
 (0)