golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.89k stars 752 forks source link

Add an OnSave option to specify either 1. which extension runs last or 2. last and/or first or 3. the extension execution order #3046

Closed pcbuildpluscoding closed 11 months ago

pcbuildpluscoding commented 11 months ago

Is your feature request related to a problem? Please describe. Yes, I submitted a bug #3044 on the basis that, for OnSave actions, gopls insists on running last and overrides my configured tab-to-spaces preference in the imports section. Unless it affects go getting, compiling, linking or testing code, gopls should really respect the user's preference.

Describe the solution you'd like An excellent result would be configuration and code that allows the user to define either 1. which extension runs last or 2. last and/or first or 3. the extension execution order.

Describe alternatives you've considered An alternative would be a change gopls so that before formatting spaces to tabs in the import section, it checks if the user has configured a preference for spaces instead of tabs.

Additional context In the answer to my #3044 bug ticket, findleyr reports "If you choose to use tabs over spaces in Go code, a lot of tools will not work as desired." I assume findleyr really meant to say 'spaces over tabs'. Please give more info in your response or point me to an online document. Thanks again

findleyr commented 11 months ago

Hi, as I described in #3044, the Go community has standardized on tabs, as enforced by gofmt.

"If you choose to use tabs over spaces in Go code, a lot of tools will not work as desired." I assume findleyr really meant to say 'spaces over tabs'. Please give more info in your response or point me to an online document

You're right, in the second half of my comment I did misspeak. However, I also linked to https://go-proverbs.github.io/: "Gofmt's style is no one's favorite, yet gofmt is everyone's favorite." Another reference is https://go.dev/doc/effective_go#formatting. It was an intentional choice by the Go community to standardize on tabs, and this convention is assumed by tools. We are unlikely to prioritize work that goes against this convention. I think one of the reasons to choose a standard is precisely so that it can be assumed by tools, thus making everything simpler.

pcbuildpluscoding commented 11 months ago

Actually, I decided to review my disagreement with gopls and why tabs-to-spaces is apparently important to me. Turns out that the pain points of my development tooling related to tabs was easily resolved if I switched my preference to tabs instead of spaces. Tabs are perhaps not evil as I previously thought! I've adjusted my github tab-size setting and changed vscode to indent with tabs on save. Closing this issue