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

Using gopls as goimports replacement produce wrong formatting #3000

Closed
powerman opened this issue Sep 4, 2020 · 0 comments · Fixed by #3004
Closed

Using gopls as goimports replacement produce wrong formatting #3000

powerman opened this issue Sep 4, 2020 · 0 comments · Fixed by #3004
Milestone

Comments

@powerman
Copy link
Contributor

powerman commented Sep 4, 2020

What did you do? (required: The issue will be closed when not provided)

let g:go_fmt_command = 'gopls'
let g:go_imports_autosave = 1
let g:go_imports_mode = 'gopls'

Open and save file with this contents:

package main
func F(*testing.T, time.Time) {}

The result will be:

package main
import (
	"testing"
	"time"
)
func F(*testing.T, time.Time) {}

which is weird because gopls imports executed in console produce a bit different result:

package main

import (
	"testing"
	"time"
)
func F(*testing.T, time.Time) {}

What did you expect to happen?

vim-go output should match gopls imports's one.
A bit more details are in #2993 (comment)

What happened instead?

vim-go output differs from gopls imports.

Configuration (MUST fill this out):

vim-go version:

bf2dd52

vimrc you used to reproduce:

vimrc
let g:go_fmt_command = 'gopls'
let g:go_imports_autosave = 1
let g:go_imports_mode = 'gopls'

Vim version (first three lines from :version):

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jul 20 2020 21:21:41)
Included patches: 1-360
Modified by Gentoo-8.2.0360

Go version (go version):

go version go1.15.1 linux/amd64

Go environment

go env Output:
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/powerman/.cache/go-build"
GOENV="/home/powerman/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/powerman/go/pkg/mod"
GONOPROXY="github.com/dentalcpdpro,github.com/mtgroupit,gitlab.qarea.org"
GONOSUMDB="github.com/dentalcpdpro,github.com/mtgroupit,gitlab.qarea.org"
GOOS="linux"
GOPATH="/home/powerman/go"
GOPRIVATE="github.com/dentalcpdpro,github.com/mtgroupit,gitlab.qarea.org"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="x86_64-pc-linux-gnu-gcc"
CXX="x86_64-pc-linux-gnu-g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build494885945=/tmp/go-build -gno-record-gcc-switches"

gopls version

gopls version Output:
golang.org/x/tools/gopls 0.4.4
    golang.org/x/tools/[email protected] h1:8djGYsaZ0ByP0vaXg4T+mnyfDcHpWKSZ+tpQSGv9ahk=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants