-
Notifications
You must be signed in to change notification settings - Fork 791
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
Support custom formatters with args #3729
Comments
Reading the source code, the language server isn't used when you set "go.formatTool" to "custom". The arguments for custom formatter work for me properly.
Could you check if this command prints out the full code to |
@logica0419 Are you sure this configuration work? When I copy paste your settings it does not work for me. There is a formatter running, and it might be golangci-lint, but it's not using the args. For example providing an illegal argument still works:
Also when comparing the output when running the tool directly I get two different results. I see that |
@palsivertsen The format error may be displayed in the dev tools console (you can see it by clicking Help > Toggle Developer Tools), so could you check if some errors are displayed there? |
There are no errors in the debug console. I cleared all settings (user and workspace json files) and uninstalled all extensions except go. This is the only thing I have in my settings file: {
"go.formatTool": "custom",
"go.alternateTools": {
"customFormatter": "golangci-lint"
},
"go.formatFlags": [
"fmt",
"--stdin",
"--no-config",
"--enable",
"gci"
]
} Note I added package example
import (
"github.com/aws/aws-sdk-go-v2/aws"
"fmt"
"io"
"log"
)
func Example() {
var (
_ = aws.SDKVersion
_ = io.EOF
_ = log.Print
_ = fmt.Print
)
} When I run this through the formatter I get the expected results: golangci-lint fmt --stdin --no-config --enable gci < example.go package example
import (
"fmt"
"io"
"log"
"github.com/aws/aws-sdk-go-v2/aws"
)
func Example() {
var (
_ = aws.SDKVersion
_ = io.EOF
_ = log.Print
_ = fmt.Print
)
} When I run the formatter in vscode I get a different result: package example
import (
"github.com/aws/aws-sdk-go-v2/aws"
"fmt"
"io"
"log"
)
func Example() {
var (
_ = aws.SDKVersion
_ = io.EOF
_ = log.Print
_ = fmt.Print
)
} This do match the results of running |
I'm trying to set up gci as my formatter for more control over import arrangement. I think I've found the relevant extensions, but I can not get the arguments to work. Here's a configuration example:
Looking at the docs it seems like the args are just ignored:
I would have more control if I could configure formatting like so:
The text was updated successfully, but these errors were encountered: