Create a .golangci.yml file in the current working directory with the following options:
linters:
enable-all: true
The following go file:
package main
import "fmt"
func main() {
fmt.Println("vim-go")
}
Running :GoMetaLinter should result in no errors.
1 || level=error msg="Running error: --enable-all and --disable-all options must not be combined"
I think this is the version of vim-go I'm running, I use vim-plug and all of my dependencies are up to date. Is there a command or something I can run to check the exact version?
vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):set nocompatible
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
call plug#end()
let g:go_fmt_command = "goimports"
let g:go_metalinter_command = "golangci-lint"
:version):VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 3 2019 04:49:45)
macOS version
Included patches: 1-1450
Compiled by Homebrew
go version):go version go1.12.5 darwin/amd64
go env Output:
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/wayneberry/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/wayneberry/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.5/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/wayneberry/Desktop/vim-go-test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/6l/rh9k25251256xljv1_wh08_00000gn/T/go-build768029044=/tmp/go-build -gno-record-gcc-switches -fno-common"
This seems like a bug in golanci-lint to me. The last one should win. As-is, there's not much for vim-go to do here.
@bhcleek I understand golangci-lint making this decision, regardless of if it is correct or not — but I definitely think there should be a way for me to configure which flags vim-go passes to the linter by default. Configurable flags in vim-go would handle this use case, but would be a welcome addition for many other settings that you might want in your editor but not when running the linter from the command-line.
I think vscode-go handles this fairly well https://github.com/microsoft/vscode-go#linter
Are you willing to make a specific option for this so people can use the enable-all: true option in the golangci-lint config? (should I open a new issue for this?)
Setting golangci-lint run as g:go_metalinter_command gives issues with golangci-lint output parsing.
For people having the same issue you can solve it by commenting out line 415
https://github.com/fatih/vim-go/blob/b995086646f29de25acbe7df2c08cc196c4641d7/autoload/go/lint.vim#L414-L416
and setting let l:default_enabled = [] for both pieces of code
@42wim take a look at the current CHANGELOG.md:
Support golangci-lint config file by not using --disable-all when g:go_metalinter_enable or g:go_metalinter_autosave_enabled is set to an empty array. [GH-2655] [GH-2715]
@bhcleek thanks! that does the job indeed.
let g:go_metalinter_autosave_enabled = []
let g:go_metalinter_enabled = []
Sorry for the noise
Most helpful comment
@bhcleek thanks! that does the job indeed.
Sorry for the noise