Skip to content

Commit 13a50d8

Browse files
authored
Merge pull request #2494 from rbisewski/rbisewski/vim-go/2489-drop-gometalinter-support
Dropping support for the depreciated gometalinter tool
2 parents 5ab8b73 + 385da04 commit 13a50d8

File tree

4 files changed

+19
-62
lines changed

4 files changed

+19
-62
lines changed

autoload/go/lint.vim

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function! go#lint#Gometa(bang, autosave, ...) abort
1111

1212
let l:metalinter = go#config#MetalinterCommand()
1313

14-
if l:metalinter == 'gometalinter' || l:metalinter == 'golangci-lint'
14+
if l:metalinter == 'golangci-lint'
1515
let cmd = s:metalintercmd(l:metalinter)
1616
if empty(cmd)
1717
return
@@ -32,14 +32,7 @@ function! go#lint#Gometa(bang, autosave, ...) abort
3232
" will be cleared
3333
redraw
3434

35-
if l:metalinter == "gometalinter"
36-
" Include only messages for the active buffer for autosave.
37-
let include = [printf('--include=^%s:.*$', fnamemodify(expand('%:p'), ":."))]
38-
if go#util#has_job()
39-
let include = [printf('--include=^(vet: \.[\\/])?%s:.*$', expand('%:p:t'))]
40-
endif
41-
let cmd += include
42-
elseif l:metalinter == "golangci-lint"
35+
if l:metalinter == "golangci-lint"
4336
let goargs[0] = expand('%:p:h')
4437
endif
4538
endif
@@ -52,18 +45,10 @@ function! go#lint#Gometa(bang, autosave, ...) abort
5245

5346
let cmd += goargs
5447

55-
if l:metalinter == "gometalinter"
56-
" Gometalinter can output one of the two, so we look for both:
57-
" <file>:<line>:<column>:<severity>: <message> (<linter>)
58-
" <file>:<line>::<severity>: <message> (<linter>)
59-
" This can be defined by the following errorformat:
60-
let errformat = "%f:%l:%c:%t%*[^:]:\ %m,%f:%l::%t%*[^:]:\ %m"
61-
else
62-
" Golangci-lint can output the following:
63-
" <file>:<line>:<column>: <message> (<linter>)
64-
" This can be defined by the following errorformat:
65-
let errformat = "%f:%l:%c:\ %m"
66-
endif
48+
" Golangci-lint can output the following:
49+
" <file>:<line>:<column>: <message> (<linter>)
50+
" This can be defined by the following errorformat:
51+
let errformat = "%f:%l:%c:\ %m"
6752

6853
if go#util#has_job()
6954
call s:lint_job({'cmd': cmd, 'statustype': l:metalinter, 'errformat': errformat}, a:bang, a:autosave)
@@ -232,9 +217,7 @@ function! s:lint_job(args, bang, autosave)
232217

233218
if a:autosave
234219
let l:opts.for = "GoMetaLinterAutoSave"
235-
" s:metalinterautosavecomplete is really only needed for golangci-lint,
236-
" but s:lint_job doesn't know whether golangci-lint is being called or
237-
" whether gometalinter is being called, so hook it up in either case.
220+
" s:metalinterautosavecomplete is really only needed for golangci-lint
238221
let l:opts.complete = funcref('s:metalinterautosavecomplete', [expand('%:p:t')])
239222
endif
240223

@@ -248,29 +231,14 @@ function! s:metalintercmd(metalinter)
248231
let l:cmd = []
249232
let bin_path = go#path#CheckBinPath(a:metalinter)
250233
if !empty(bin_path)
251-
if a:metalinter == "gometalinter"
252-
let l:cmd = s:gometalintercmd(bin_path)
253-
elseif a:metalinter == "golangci-lint"
234+
if a:metalinter == "golangci-lint"
254235
let l:cmd = s:golangcilintcmd(bin_path)
255236
endif
256237
endif
257238

258239
return cmd
259240
endfunction
260241

261-
function! s:gometalintercmd(bin_path)
262-
let cmd = [a:bin_path]
263-
let cmd += ["--disable-all"]
264-
265-
" gometalinter has a --tests flag to tell its linters whether to run
266-
" against tests. While not all of its linters respect this flag, for those
267-
" that do, it means if we don't pass --tests, the linter won't run against
268-
" test files. One example of a linter that will not run against tests if
269-
" we do not specify this flag is errcheck.
270-
let cmd += ["--tests"]
271-
return cmd
272-
endfunction
273-
274242
function! s:golangcilintcmd(bin_path)
275243
let cmd = [a:bin_path]
276244
let cmd += ["run"]

autoload/go/lint_test.vim

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
let s:cpo_save = &cpo
33
set cpo&vim
44

5-
func! Test_Gometa() abort
6-
call s:gometa('gometalinter')
7-
endfunc
8-
95
func! Test_GometaGolangciLint() abort
106
call s:gometa('golangci-lint')
117
endfunc
@@ -21,7 +17,7 @@ func! s:gometa(metalinter) abort
2117
\ ]
2218
if a:metalinter == 'golangci-lint'
2319
let expected = [
24-
\ {'lnum': 5, 'bufnr': bufnr('%')+1, 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function `MissingFooDoc` should have comment or be unexported (golint)'}
20+
\ {'lnum': 5, 'bufnr': bufnr('%')+2, 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function `MissingFooDoc` should have comment or be unexported (golint)'}
2521
\ ]
2622
endif
2723

@@ -46,10 +42,6 @@ func! s:gometa(metalinter) abort
4642
endtry
4743
endfunc
4844

49-
func! Test_GometaAutoSave() abort
50-
call s:gometaautosave('gometalinter')
51-
endfunc
52-
5345
func! Test_GometaAutoSaveGolangciLint() abort
5446
call s:gometaautosave('golangci-lint')
5547
endfunc

doc/vim-go.txt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ experience.
5151
* Precise type-safe renaming of identifiers with |:GoRename|.
5252
* See which code is covered by tests with |:GoCoverage|.
5353
* Add or remove tags on struct fields with |:GoAddTags| and |:GoRemoveTags|.
54-
* Call `gometalinter` with |:GoMetaLinter| to invoke all possible linters
54+
* Call `golangci-lint` with |:GoMetaLinter| to invoke all possible linters
5555
(`golint`, `vet`, `errcheck`, `deadcode`, etc.) and put the result in the
5656
quickfix or location list.
5757
* Lint your code with |:GoLint|, run your code through |:GoVet| to catch
@@ -652,7 +652,7 @@ CTRL-t
652652
*:GoMetaLinter*
653653
:GoMetaLinter! [path]
654654

655-
Calls the underlying `gometalinter` tool and displays all warnings and
655+
Calls the underlying `golangci-lint` tool and displays all warnings and
656656
errors in the |quickfix| window. By default the following linters are
657657
enabled: `vet`, `golint`, and `errcheck`. This can be changed with the
658658
|'g:go_metalinter_enabled'| variable. To override the command completely
@@ -833,7 +833,7 @@ CTRL-t
833833

834834
Toggles |'g:go_metalinter_autosave'|.
835835

836-
By default, `gometalinter` messages will be shown in the |location-list|
836+
By default, `golangci-lint` messages will be shown in the |location-list|
837837
window. The list to use can be set using |'g:go_list_type_commands'|.
838838

839839
*:GoTemplateAutoCreateToggle*
@@ -1512,7 +1512,7 @@ function when using the `af` text object. By default it's enabled. >
15121512
Use this option to auto |:GoMetaLinter| on save. Only linter messages for
15131513
the active buffer will be shown.
15141514

1515-
By default, `gometalinter` messages will be shown in the |location-list|
1515+
By default, `golangci-lint` messages will be shown in the |location-list|
15161516
window. The list to use can be set using |'g:go_list_type_commands'|.
15171517

15181518
By default it's disabled >
@@ -1541,12 +1541,11 @@ it's empty
15411541
<
15421542
*'g:go_metalinter_command'*
15431543

1544-
Overrides the command to be executed when |:GoMetaLinter| is called. By
1545-
default it's `gometalinter`. `golangci-lint` is also supported. It can also be
1546-
used as an advanced setting for users who want to have more control over
1547-
the metalinter.
1544+
Overrides the command to be executed when |:GoMetaLinter| is called. By
1545+
default it's `golangci-lint`. It can also be used as an advanced setting
1546+
for users who want to have more control over the metalinter.
15481547
>
1549-
let g:go_metalinter_command = "gometalinter"
1548+
let g:go_metalinter_command = "golangci-lint"
15501549
<
15511550
*'g:go_metalinter_deadline'*
15521551

@@ -2351,9 +2350,9 @@ while saving and opening files. The following fixes this:
23512350
let g:syntastic_go_checkers = ['golint', 'govet']
23522351
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
23532352
<
2354-
If you want to add errcheck you can use gometalinter as a wrapper
2353+
If you want to add errcheck you can use golangci-lint as a wrapper:
23552354
>
2356-
let g:syntastic_go_checkers = ['golint', 'govet', 'gometalinter']
2355+
let g:syntastic_go_checkers = ['golint', 'govet', 'golangci-lint']
23572356
let g:syntastic_go_gometalinter_args = ['--disable-all', '--enable=errcheck']
23582357
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
23592358
<

plugin/go.vim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ let s:packages = {
4949
\ 'goimports': ['golang.org/x/tools/cmd/goimports'],
5050
\ 'golint': ['golang.org/x/lint/golint'],
5151
\ 'gopls': ['golang.org/x/tools/gopls@latest', {}, {'after': function('go#lsp#Restart', [])}],
52-
\ 'gometalinter': ['github.com/alecthomas/gometalinter'],
5352
\ 'golangci-lint': ['github.com/golangci/golangci-lint/cmd/golangci-lint'],
5453
\ 'gomodifytags': ['github.com/fatih/gomodifytags'],
5554
\ 'gorename': ['golang.org/x/tools/cmd/gorename'],
@@ -183,7 +182,6 @@ function! s:GoInstallBinaries(updateBinaries, ...)
183182
let l:get_cmd += ['-u']
184183
endif
185184

186-
" GO111MODULE must be off to install gometalinter.
187185
let Restore_modules = go#util#SetEnv('GO111MODULE', 'off')
188186

189187
" first download the binary

0 commit comments

Comments
 (0)