When using gopls, how to increase the length at which the line is wrapped?

63 Views Asked by At

How do I increase the length of a line at which gopls will split function into multiple lines? I've disabled go language server and it stopped splitting the line so gopls is the cause and I'm hoping there is setting somewhere to change the default.

For example this code:

func A() { return /* this code will wrap if you paste this into vs code <...........................> */ }

func B() { return /* this code will not wrap if you paste this into vs code <......................> */ }

will get split like this:

func A() {
    return /* this code will wrap if you paste this into vs code <...........................> */
}

func B() { return /* this code will not wrap if you paste this into vs code <......................> */ }

1

There are 1 best solutions below

0
starball On

I don't do Go development, so I might be wrong, but looking at the gopls docs, the only formatting settings are local and gofumpt, and go.formatFlags and go.formatTool. And go.formatFlags is only relevant when not using the language server for formatting.

So I think you'd need to use some other formatting option (go.formatTool) to have more control over how formatting works.

Though again, I'm no Go dev, so take what I say with a grain of salt. I'd be happy to be wrong.