Skip to content

x/tools/gopls: implement code action to split and group args/elements/return values into single/separate lines #65156

Closed
@fatanugraha

Description

@fatanugraha

gopls version

v0.14.2

go env

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/fatanugraha/Library/Caches/go-build'
GOENV='/Users/fatanugraha/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/fatanugraha/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/fatanugraha/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.21.6/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.21.6/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/xw/9_n8jx3101g27v376tld9qbw0000gn/T/go-build3470959707=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Implement a code action to easily refactor function arguments, return values, and composite literal elements into separate lines or a single line.

This feature would be particularly helpful when working on large business-related features that often require long variable names. The ability to quickly split or group lines would significantly accelerate refactoring efforts to ensure code adheres to specified character limits.

for example:

// original code
func A(a int, b int, c int) (d int, e int) {
   ...
}

[]int{1,2,3}

// put args to separate lines
func A(
    a int, 
    b int, 
    c int,
) (d int, e int) {
   ...
}

// put return values to separate lines
func A(a int, b int, c int) (
    d int, 
    e int,
) {
   ...
}

// put composite literal elements to a separate lines
[]int{
    1,
    2, 
    3,
}

What did you see happen?

The feature is not available yet on gopls.

What did you expect to see?

To see the feature in gopls.

Editor and settings

VSCode

Logs

N/A

Metadata

Metadata

Assignees

Labels

FeatureRequestIssues asking for a new feature that does not need a proposal.FrozenDueToAgeRefactoringIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions