golangci-lint
golangci-lint copied to clipboard
ability to run linter on unsaved files
Your feature request related to a problem? Please describe.
I use neovim and vim-ale to run golangci-lint automatically whenever I save a file.
vim-ale also works with gopls, which does its own linting. But vim-ale is able to use gopls as I type, even if I don't save the actual buffer.
It would be really great if there was a way to run golangci-lint on files that aren't yet saved to the disk.
Describe the solution you'd like.
I thought one option would be for vim-ale/the text editor to write the current state of files open in the editor to temporary files. Then it could pass flags into golangci-lint run that say essentially "instead of using this actual file, use the contents of this temporary file, but with the original file's name".
Another option would be for golangci-lint to act as a LSP but that seems like a lot more work.
Describe alternatives you've considered.
Of course, instead of doing this, I could set up autosave. But that triggers other stuff too, like running gofmt. It would be nice to have linting run entirely independently. That would also let me get results faster since it would be asynchronous.
Additional context.
No response
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.
Hello,
I never try or use it but maybe you are looking for something like that https://github.com/nametake/golangci-lint-langserver
Yes, unfortunately I think that just wraps golangci-lint so it implements the LSP protocol, but it still only actually runs golangci-lint when files are saved. I'm not sure it is possible to write a LSP that responds to document changes with the current API. Well, not without copying the entire working directory or something.
On Wed, Sep 14, 2022 at 2:11 PM Ludovic Fernandez @.***> wrote:
Hello,
I never try or use it but maybe you are looking for something like that https://github.com/nametake/golangci-lint-langserver
— Reply to this email directly, view it on GitHub https://github.com/golangci/golangci-lint/issues/3221#issuecomment-1247306420, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQTBUF7S54PHRO2YMWRYW3V6I5OLANCNFSM6AAAAAAQMYVRWM . You are receiving this because you authored the thread.Message ID: @.***>