I would like to use .golang-ci.yaml found in the project's root folder in the :GoMetaLinter command.
I would like to use .golang-ci.yaml found in the project's root folder in the GoMetaLinter command.
Currently, the command only considers the package straight from the file. As an example: the project is in the path /usr/ projects/goproj and it is the directory where I opened neovim. In the folder hierarchy there is a workers package. Staying like this:
goproj> workers> file1.go, file2.go
goproj> main.go
goproj> .golangci.yaml
I have the buffer open in file1.go. If I run :GoMetaLinter it will not take the project root settings and will only run for package workers.
It only ran for package workers with the default configuration in my case.
vim-go version
1.24
vimrc you used to reproduce:
vimrc
-- disable vim-go snippet engine
vim.g.go_snippet_engine = ""
-- vim-go vars
vim.g.go_fmt_command = "goimports"
vim.g.go_list_type = "quickfix"
vim.g.go_addtags_transform = "camelcase"
vim.g.go_metalinter_enabled = {}
vim.g.go_metalinter_autosave_enabled = {}
vim.g.go_auto_type_info = 1
:version):go version):
go version
1.15.4
go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/rafael.martins/Library/Caches/go-build"
GOENV="/Users/rafael.martins/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/rafael.martins/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/rafael.martins/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/0b/160561q94fl6grsd9pvfn9x80000gp/T/go-build008007327=/tmp/go-build -gno-record-gcc-switches -fno-common"
gopls version
v0.5.3
Vim-go runs golangci-lint with the working directory set to the directory that contains the active buffer. According to https://golangci-lint.run/usage/configuration/#config-file, what you're doing should work as far as I can tell. You can use use let l:go_debug=['shell-commands'] to see exactly what command vim-go is using and try it for yourself at the commandline.
It's running this one:
vim-go: job command: ['/Users/rafael.martins/go/bin/golangci-lint', 'run', '--print-issued-lines=false', '--build-tags', '', '--exclude-use-default=false', '/Users/rafael.martins/projects/goproj/workers']
When I run inside the same folder but shell directly the verbose result is this.
go run github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout 10m --verbose
INFO [config_reader] Config search paths: [./ /Users/rafael.martins/projects/goproj /Users/rafael.martins/projects/goproj/workers /Users/rafael.martins/projects /Users/rafael.martins /Users /]
INFO [config_reader] Used config file .golangci.yml
Maybe I'm misunderstanding what you want to happen. When I first read your issue, I thought you were saying that you want the golangci.yml in /Users/rafael.martins/projects/goproj to be used when the active buffer was from /Users/rafael.martins/projects/goproj/workers. After re-reading, though, I think you might be asking for /Users/rafael.martins/projects/goproj to be the directory that is linted instead of /Users/rafael.martins/projects/goproj/workers. Can you clarify for me?
Exactly the second option, I would like an open buffer in /goproj/workers/file1.go to linter this file but respecting the configuration of golangci in the root directory. It was clear?
Sorry for my English.
No worries on the language front; I'm happy to work through any language difficulties.
From what I can tell, you are seeing the behavior that you've asked for: the package in /goproj/workers is being linted and it's golangci-lint would use the /goproj/.golangci.yml to control its behavior.
Exactly.
If it's working as you expect, then shall we close this?
No, it's not using the configuration for the file1.go file lint when opened. It should run the project file that I opened when I gave the nvim command to open project.
Ok, I'm confused. You're linting /goproj/workers. golangci-lint will use the golangci.yml file that's closest to that directory. What makes you think that it's not using /goproj/.golangci.yml ? Do you have a /goproj/workers/.golangci.yml?
Exact it is not using the nearest one. There is no exist .golangci.yml in /goproj/workers/
I would like to use .golang-ci.yaml found in the project's root folder in the :GoMetaLinter command.
The project as you've described it is at /Users/rafael.martins/projects/goproj, and it contains a .golangci.yml file, and that's the config that golangci-lint is using.
So given this scenario:
/Users/rafael.martins/projects/goproj/.golangci.yml exists/Users/rafael.martins/projects/goproj/workers/.golangci.yml does _not_ exists.:GoMetaLinter in /Users/rafael.martins/projects/goproj/workersWhat config do you expect golangci-lint to use?

~/sandbox/goproj $ nvim
Opens file with :e workers/file1.go
Runs :GoMetaLinter
I would expect you to use the .golanci.yml from the folder I used nvim. But he doesn't use him.
What evidence do you see that it's _not_ using ~/sandbox/goproj/.golangci.yml? From everything that I see, that's the config file that golangci-lint would use when it lints ~/sandbox/goproj/workers.
To be clear, the working directory the vim-go uses to run the command will _always_ be set to the directory that contains the file for the active buffer. That's a separate question from which config file golangci-lint will use.
the evidence that running golancg-ci through makefile and go-vim the results are different because I take some rules out of lint.
Can you be more specific? I have no idea what's in your Makefile, what you're seeing when you run it there, or what you're seeing when you run :GoMetalinter.
# GolangCI-Lint configuration.
# See https://github.com/golangci/golangci-lint#config-file for reference.
run:
skip-dirs:
- vendor
linters-settings:
lll:
line-length: 140
tab-width: 4
maligned:
suggest-new: true
misspell:
locale: US
linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
# - funlen
# - gochecknoglobals
# - gochecknoinits
- gocognit
- goconst
- gocritic
# - gocyclo
# - godox
- gofmt
- goimports
- golint
# - gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- lll
- maligned
- misspell
- nakedret
- prealloc
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
# - wsl
issues:
exclude-rules:
# Exclude crypto/md5 from security linter
- text: "weak cryptographic primitive"
linters:
- gosec
My .golanci.yaml.
Result of :GoMetalinter on buffer workers/file2.go

Result go run

I noticed back in https://github.com/fatih/vim-go/issues/3087#issuecomment-726729842 that you did not use the same command that vim-go uses. If you use /Users/rafael.martins/go/bin/golangci-lint instead of go run github.com/golangci/golangci-lint/cmd/golangci-lint, does you see the additional stylecheck errors at your commandline that vim-go shows you?

here is the same result.
Can you please run it in the workers directory?

Please run it in the workers directory that same as vim-go does:
/Users/rafael.martins/go/bin/golangci-lint run --print-issued-lines=false --build-tags '' --exclude-use-default=false /Users/rafael.martins/projects/goproj/workers
馃 that's strange. vim-go is literally just running golangci-lint as shown. I'm not sure why you're getting those stylecheck errors in vim-go, but not at your commandline. But I did notice that the most recent command you're using is a different path than what you were reporting before. Previously, you were using /Users/rafael.martins/projects/goproj/workers, but your commandline now shows /Users/rafael.martins/sandbox/goproj/workers
It is really very strange. I changed the directory because it's just a test project that I have to delete at the end of the issue. But it remains the same project. The idea was the difference between executions.
I believe that's a bug.
I have no idea how to duplicate what you're seeing, though. Do you have any code that I can use to try to dig in more?
https://github.com/martinsrso/goproj it's a simple project simulate my official.
Thank you for providing that.
I don't see the same errors that you see (the ST1000 errors aren't there):

Do you have any other plugins enabled?
Yes, follow the plugin file: https://pastebin.com/RbM83NaX
I'm not going to parse and analyze your vimrc to figure out which of the plugins is doing this. If you're able to isolate the problem to vim-go I'll be more than happy to help find a resolution.
Ok, I thought there was already a plugin known to cause some problem or incompatibility with vim-go. I will separate here isolate and send.
Thank you very much for the clarification, I tested the plugins and as I am with the nightly version of neovim the plugin was incompatible with vim-go. And thanks again for your patience and time.