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: placeholder still exists when usePlaceholders is false #62676

Closed
ch3n9w opened this issue Sep 16, 2023 · 3 comments
Closed

x/tools/gopls: placeholder still exists when usePlaceholders is false #62676

ch3n9w opened this issue Sep 16, 2023 · 3 comments
Assignees
Labels
gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@ch3n9w
Copy link

ch3n9w commented Sep 16, 2023

gopls version

Build info
----------
golang.org/x/tools/gopls v0.13.2
    golang.org/x/tools/gopls@v0.13.2 h1:Pyvx6MKvatbX3zzZmdGiFRfQZl0ohPlt2sFxO/5j6Ro=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA
=
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH
3x7MAiqGW6Y=
    golang.org/x/mod@v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
    golang.org/x/sync@v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
    golang.org/x/sys@v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
    golang.org/x/text@v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
    golang.org/x/tools@v0.11.2-0.20230810185051-cc6b5804b8cf h1:Oush7UwPamr2/iNeNFBuNFj89YyHn0YY69EKDd
vANnk=
    golang.org/x/vuln@v0.0.0-20230110180137-6ad3e3d07815 h1:A9kONVi4+AnuOr1dopsibH6hLi1Huy54cbeJxnq4vm
U=
    honnef.co/go/tools@v0.4.2 h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc=
    mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
    mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.21.0

go env

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/ch4ser/.cache/go-build'
GOENV='/home/ch4ser/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/ch4ser/Projects/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ch4ser/Projects/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build248562473=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I use golsp with nvim-lspconfig and nvim-cmp in neovim. The golsp related configuration is following:

local lspconfig = require('lspconfig')
lspconfig.gopls.setup {
    capabilities = capabilities,
    single_file_mode = false,
    root_dir = lspconfig.util.root_pattern("go.mod"),
    settings = {
        gopls = {
            experimentalPostfixCompletions = true,
            analyses = {
                unusedparams = true,
                shadow = true,
            },
            staticcheck = true,
            hints = {
                assignVariableTypes = true,
                compositeLiteralFields = true,
                compositeLiteralType = true,
                constantValues = true,
                functionTypeParameters = true,
                parameterNames = true,
                rangeVariableTypes = false,
            },
            usePlaceholders = false,
        },
    },
}

Then I create a new project and try to input os.Op, I accept the completion suggestion os.Open

What did you expect to see?

The unimport package os is imported, and code is shown as os.Open() with no placeholder.

What did you see instead?

The unimport package os is imported, and code is shown as os.Open(name).
However, if I import os package manually before input os.Op, the completion result contains no placeholder as expected.

Logs

the log file is empty when I use gopls -logfile /home/ch4ser/gopls.log

@ch3n9w ch3n9w 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 Sep 16, 2023
@gopherbot gopherbot added this to the Unreleased milestone Sep 16, 2023
@findleyr
Copy link
Contributor

Thanks for the report. Yes, this is a bug in unimported completion, which appears not to be honoring usePlaceholders.

@findleyr findleyr modified the milestones: Unreleased, gopls/v0.14.0 Sep 18, 2023
@findleyr findleyr added the gopls/completion Issues related to auto-completion in gopls. label Sep 20, 2023
@findleyr findleyr self-assigned this Sep 27, 2023
@gopherbot
Copy link

Change https://go.dev/cl/531458 mentions this issue: gopls/internal/regtest/source/completion: reuse functionCallSnippet in

@Shane-XB-Qian
Copy link

@findleyr seems this had been fixed & i cannot repro again at v0.14.0.pre.4, howerver another case:
it cannot complete os. no complete items e.g OpenFile, is it similar issue? or if you need another ticket, i can open one.

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

No branches or pull requests

4 participants