Skip to content
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

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

Closed
fatanugraha opened this issue Jan 18, 2024 · 1 comment
Assignees
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@fatanugraha
Copy link

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

@fatanugraha fatanugraha added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Jan 18, 2024
@gopherbot gopherbot added this to the Unreleased milestone Jan 18, 2024
@fatanugraha fatanugraha changed the title x/tools/gopls: implement split and group args/elements/return values into single/separate lines. x/tools/gopls: implement code action to split and group args/elements/return values into single/separate lines Jan 18, 2024
@hyangah hyangah added the Refactoring Issues related to refactoring tools label Jan 18, 2024
@suzmue suzmue modified the milestones: Unreleased, gopls/backlog Jan 24, 2024
@gopherbot
Copy link

Change https://go.dev/cl/558475 mentions this issue: gopls: implement code action to split/group lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
4 participants