Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: golangci-lint support with go-vim #1841

Closed
stefanos82 opened this issue May 26, 2018 · 18 comments
Closed

Request: golangci-lint support with go-vim #1841

stefanos82 opened this issue May 26, 2018 · 18 comments

Comments

@stefanos82
Copy link

The project description sounds very nice!

Linters Runner for Go. 5x faster than gometalinter.

https://github.com/golangci/golangci-lint

@venjiang
Copy link

when?

@fatih
Copy link
Owner

fatih commented May 28, 2018

I'm not sure how maintainable this project is. It vendors and modifies all current linters: https://github.com/golangci/golangci-lint#internals It just doesn't vendor them, it even changes them and modifies them to a point that they are not the same anymore. How can I be sure that vet is the same original vet when I call golangci-lint? gometalinter might be slow, but you can be assured it's using the original tool and source, instead of a modified one.

I'm not saying it's the wrong way or etc.. I know they have a product offering and trying to earn money with this project, but we have to keep vim-go in a maintainable state. The last thing we want is to fix bugs that might be caused by third-party linter forks.

I'm not going to close this for now, happy to read other people thoughts on this.

@golangci
Copy link

@fatih we're upstreaming changes and it will take some time to prepare changes, review and merge them by linters authors.

The problem with vet is that it lives in go source code: it's too big repo to vendor it. First we decided to make subtree of go source code with only vet code, but even this repo cloning was super-slow because of long git history. Therefore we've just made a copy of vet source code and you can't be sure that it's the same original vet. It has pros (users of old go version can use newer vet) and cons (not official way, less guarantees).

@powerman
Copy link
Contributor

powerman commented Jun 7, 2018

Maybe something has changed since I've tried to auto-run gometalinter on file save, but at that time it was incredible slow - wait for 1-3 seconds on each save is not an option. So, I give up and run it manually in console before pushing changes and within CI. If golangci-lint will be fast enough to make it possible to auto-run it on save without noticeable slowdown of vim - I think it's worth to support! Even if it uses modified linters and even if they behave a bit differently - it's just a linters, if they catch most of issues then it's better than nothing.

At a glance it looks like it may be that fast, but only when called with --fast flag, otherwise it takes about 3 seconds - too slow to auto-run on save.

@jirfag
Copy link

jirfag commented Jun 18, 2018

Hi!
I am the author of golangci-lint.
I just want to note that this issue is the most liked issue in your repo and golangci-lint is already integrated with VS Code, Sublime, Goland, GNU Emacs.

@empijei
Copy link

empijei commented Feb 2, 2019

I'd add this https://twitter.com/alecthomas/status/1091467762625474560?s=19

@dgryski
Copy link

dgryski commented Feb 2, 2019

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 2, 2019

Thanks for the updates. Especially given Alec Thomas's comments, it seems like replacing gometalinter in vim-go is warranted. After golsp intergration is merged (the focus of my current efforts for vim-go), I can get started on replacing gometalinter if no one else submits the PR before then.

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 2, 2019

For anyone following along and looking for this issue to be resolved with formal support in vim-go, you may be able to start using golangci-lint as-is by leveraging g:go_metalinter_command in the interim.

@stmuk
Copy link

stmuk commented Feb 11, 2019

or add the following to your .vimrc

command GOLINT :cexpr system('golangci-lint run')

and use :GOINT (the first character has to capitalised but not those following!

@vrischmann
Copy link
Contributor

@bhcleek I'm trying that right now but I can't seem to make it so I can jump to the lines from the output. Did you manage to make that work ?

@tanishq-dubey
Copy link

Is there more documentation for the g:go_metalinter_command setting?

@danilopopeye
Copy link

Is there more documentation for the g:go_metalinter_command setting?

vim-go/doc/vim-go.txt

Lines 1499 to 1506 in 66d06f3

*'g:go_metalinter_command'*
Overrides the command to be executed when |:GoMetaLinter| is called. This is
an advanced settings and is for users who want to have a complete control
over how `gometalinter` should be executed. By default it's empty.
>
let g:go_metalinter_command = ""
<

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 28, 2019

@vrischmann I haven't tried it. If golangci-lint's output is formatted differently than gometalinter's, then it's unlikely to work.

gometalinter mostly works, so this issue is a lower priority for me than getting the gopls intergration going. Once I get done with that, I'll put some attention to moving from gometalinter to golangci-lint.

@micahcoffman
Copy link
Contributor

I started a WIP here, but some of the details of what we want the default config to look like still need to get hashed out #2182

@jonaz
Copy link

jonaz commented Mar 21, 2019

https://github.com/alecthomas/gometalinter
gometalinter is DEPRECATED and the project will be archived on 2019-04-07.

Would be nice to have golangci-lint as a replacement since thats they are recomending.

@hollowaykeanho
Copy link

hollowaykeanho commented Mar 27, 2019

While waiting for golangci-lint, I would like to share my current workaround using ~/.vimrc. Let me know what else I can help to accelerate the effort.

" go programming language
autocmd BufWritePost *.go !gofmt -w -s %:p
autocmd BufWritePost *.go !clear && golangci-lint run --color never --enable-all %:p:h

Tested on Debian Stretch.

@bhcleek
Copy link
Collaborator

bhcleek commented Mar 27, 2019

golangci-lint support was added in #2182

@bhcleek bhcleek closed this as completed Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests