Skip to content

Support custom formatters with args #3729

Open
@palsivertsen

Description

@palsivertsen

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:

{
  "go.alternateTools": {
    "customFormatter": "gci"
  },
  "go.formatFlags": [
    "print",
    "--custom-order",
    "--section=standard",
    "--section=default",
    "--section=blank",
    "--section=dot",
    "--section=alias",
    "--section=localmodule"
  ],
  "[go]": {
    "editor.defaultFormatter": "golang.go"
  },
  "go.formatTool": "custom"
}

Looking at the docs it seems like the args are just ignored:

Flags to pass to format tool (e.g. ["-s"]). Not applicable when using the language server.

I would have more control if I could configure formatting like so:

{
  "go.formatTool": {
    "command": "gci",
    "arguments": [
      "print",
      "--custom-order",
      "--section=standard",
      "--section=default",
      "--section=blank",
      "--section=dot",
      "--section=alias",
      "--section=localmodule"
    ],
    "passFileOn": "stdin"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions