Closed pjkaufman closed 6 months ago
Hey
Unfortunately, efm only runs on a single file. That's what it was designed to do :(
Golangci-lint behaves very differently to any other normal linters out there.
Can you provide me with a sample go repo with some steps so I can try it out and see if there is some alternative that I can give for your specific usecase?
Hey @creativenull , I tried linting the following file via neovim: https://github.com/pjkaufman/dotfiles/blob/cf114c605385bba6eafb6c13dfbd08cf5c8e53fc/go-tools/ebook-lint/cmd/epub/compress-and-lint.go
Is that something that you can use to reproduce this issue or do I need to try to break something out into its own repo?
Yeah I think that should be good, I see go-tools is the go project so I can start from there.
In the meantime, maybe try out null-ls (https://github.com/nvimtools/none-ls.nvim) plugin or my other plugin diagnosticls-configs (https://github.com/creativenull/diagnosticls-configs-nvim) and see if that works.
I see that they use the json format from golangci-lint, which efm cannot parse at this moment.
I see that efm runs on the root directory for C#. Is that a one off or could that kind of thing be replicated if I were to add the ability to get the folder of the current file to https://github.com/mattn/efm-langserver/blob/d1e53448d16a2b20440faab406b625efe9792653/langserver/handler.go#L705-L708?
Yes, that is correct efm will run on the project root. Just that efm will inject ${INPUT}
at the end of a command if no file was specified. That is why it keeps giving you errors based on the file.
So I've tried out your project and it doesn't seem like it works as it was intended by efm.
However, this works as expected with null-ls so I'd say you will have to go with that for now, sorry this one didn't work out for you.
When I have time I will look into contributing to the efm repo for this feature.
Gotcha. Thanks for the response and taking a look into this!
Hey guys. Thank you for this repo that helps add linters and formatters into Neovim.
I was setting up
golangci_lint
and I seem to have hit a bit of a problem. I am trying to use it like I did in VSCode where it allowed you to specify that on lint you would lint the current package. I looked into how that would be done and from what I could gather it would be something likegolangci_lint run
without a file provided. So I tried looking into how things are currently being done and noticed that golangci_lint is configured to run on a single file which causes variables defined in other files in the same package to come back with errors.Is there a way I can change this to run on the current package (i.e. the current folder) for my own use at the very least? I ask because I tried the following, but it does not seem to work as it does not remove the typecheck errors about variables not defined or does no linting at all:
I do see that the file replacement seems to happen here which does not seem to have the current folder as an option: https://github.com/mattn/efm-langserver/blob/d1e53448d16a2b20440faab406b625efe9792653/langserver/handler.go#L705-L708 But I am not sure if that is me misunderstanding things or if there truly is no option to run a linter on the current folder instead of the current file. If there is no option to lint the current folder, I can make an FR and possibly a PR for the efm language server.
If more info is needed, please let me know.