-
Notifications
You must be signed in to change notification settings - Fork 752
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
Allow specifying random formatting tools instead of four fixed options #587
Comments
Try I am afraid that replacing the selector with a textbox would make common cases less visible. And the extension has some specializations depending on the chosen tool (e.g. flags) so support for arbitrary tools will not work perfectly. |
@hyangah so the recommended way of using any formatter (not specifically And also this method feels does not feel completely right. The workaround I mentioned in my OP works but it triggers a I think that if this is the recommended way, it should at least be clearly indicated in the UI and the Edit: maybe another alternative could be not to replace the dropdown with a textbox, but instead keep it and add an extra textbox for other formatters. If set, it would take precedence over the |
@xabinapal If you find a way to add an extra textbox in addition to the dropdown, please send a PR. The UI is implemented by VS Code, so I'd like to know how to do it.
|
Change https://golang.org/cl/251897 mentions this issue: |
As I don't think that a mix of a dropdown+textbox setting is possible, I've submitted a PR that simply adds two new nullable textbox properties for the lint and the format tools. By allowing |
@xabinapal Thanks for trying to fix this, but I am not sure if introducing two extra settings is a good idea. A good news is that we are planning to default to |
Obviously using Thank you! |
If your goal is to use |
Change https://golang.org/cl/252922 mentions this issue: |
Sorry, I missed your answer! I've just seen that you have submitted the patch you suggested, that's great! Thank you! |
gofumpt and gofumports can be used as drop-in replacements of gofmt and goimports, so we directed users to utilize `"go.alternateTools"` (https://github.com/mvdan/gofumpt#installation) However, this is pretty convoluted and less user-friendly. As more users are adopting gofumpt and gofumports, promote them as officially recognized formatters. It would be ideal if the extension allows to choose any formatter as long as the tool follows a certain spec, but we are not there yet. And, as we are moving towards using the language server as the formatter, this setting will become obsolete. Updates #587 Change-Id: Ib1fc5c91c0d6fc7fed37132c6cbd0dfa44b6a08b Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/252922 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Suzy Mueller <suzmue@golang.org>
@xabinapal thanks for understanding - hopefully, we can come up with more user-friendly ways of configuring formatter etc with gopls soon. I will close this issue for now. |
Is your feature request related to a problem? Please describe.
Current extension settings only allow to select
gofmt
,goimports
,goreturns
andgoformat
as formatters. There are other formatting tools that one would want to use, but this is not allowed.Describe the solution you'd like
gofumpts
andgofumports
are two known alternatives togofmt
andgoimports
. It would be nice to be allowed to use them, or any other formatter tool. This should be allowed by using a textbox instead of a selector for this property, with maybe suggestions for the current options.Describe alternatives you've considered
As a workaround, manually modifying the property
go.formatTool
in thesettings.json
file allows to usegofumports
as the formatting tool. By doing this, VS Code complains about an invalid value for that setting, but even with that warning,gofumports
is used and code is formatted as expected.Additional context
gopls
just added support forgofumpts
, so it can used by enabling it in the language server (with some undocumented settings, but this is already stated in it's documentation), but not everybody can use it, so it would be nice to add this feature.The text was updated successfully, but these errors were encountered: