-
Notifications
You must be signed in to change notification settings - Fork 918
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
feat(go): add gofumpt formatter with conform/none-ls #1683
Conversation
This workaround can be removed once LazyVim/LazyVim#1683 is merged
Also, this is my first time contributing to the project. Please do let me know if in the future you'd like me to first create an issue or similar. Thanks ❤️ |
I'm still catching up myself on the new interaction between conform, none-ls, and the primary/secondary formatters. But would this now enforce the use of gofumpt if none-ls is enabled? That's certainly doesn't seem desirable, since gofumpt is far from standard in the Go community. |
With this PR, Of course, if someone does not wish to use |
I would argue that having gofumpt enabled by default pre-10.0.0 was a mistake. If someone wants to use it, they could always add it, could they not? |
That's a good argument, I guess it ends up as a matter of preference. I'm happy with closing this if other people agree. Out of curiosity, do you regularly use a different formatter yourself? |
Yeah, it's always tricky to pick the "right" set of defaults for a project like this. It definitely often comes down to individual preference. The fact that I just the default |
If I understand correctly, the ideal case is golsp being the primary formatter and goimports being a secundary? If so I can change it like that. |
I sort of disagree with this. @folke It does seem to work for me, but yes |
Yeah it would be nice to have gofumpt as the default, gofumpt got (unnecessarily imo) removed when someone updated the spec a while back |
@amaanq I don't think
|
So I agree that it's probably best to merge this PR and get back to how it was before. |
Just want to give my thought on this but imo the current way of handling formatters is less flexible than the old one. The old way allowed us to disable null-ls in favour of lsp in some languages. |
That's not true. It's pretty much the same as with null-ls. You can change the conform formatters_by_ft for go and set it to an empty list so that the lsp will be used instead. Thats' the same as it was before |
In case it helps anyone, here's my conform setup for go where I can remove/extend/replace per file type: https://github.com/fredrikaverpil/dotfiles/blob/3d58a40bf2a9cc13546cf9e1aaaef93750c47c5e/nvim-lazyvim/lua/plugins/lsp.lua#L163-L189 |
Thank you sir @folke. This is awesome. |
After #1535 and #1549, some formatters (i.e.:
gofumpt
) were removed from theconform.nvim
andnone-ls.nvim
configurations inextras.lang.go
because they were already already handled by the LSPgopls
.With the release of LazyVim 10.0.0, only one formatter can be active at a time so
gopls
is no longer taking care of runninggofumpt
whenconform
ornone-ls
are active.This PR adds it back to the
conform.nvim
andnone-ls.nvim
configurations so people using any of the two can usegofumpt
. This PR also makes sure packages are only installed when strictly necessary: for example,delve
is only needed whennvim-dap
is available andgomodifytags
andimpl
are not supported by conform since they are code actions, so they are only installed when usingnone-ls
.