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: no completions provided in some seemingly straightforward cases #69492

Open
cespare opened this issue Sep 16, 2024 · 2 comments
Open
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

@cespare
Copy link
Contributor

cespare commented Sep 16, 2024

gopls version

Build info
----------
golang.org/x/tools/gopls v0.16.2
    golang.org/x/tools/[email protected] h1:K1z03MlikHfaMTtG01cUeL5FAOTJnITuNe0TWOcg8tM=
    github.com/BurntSushi/[email protected] h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/[email protected] h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/[email protected] h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
    golang.org/x/[email protected] h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
    golang.org/x/[email protected] h1:Wm3cG5X6sZ0RSVRc/H1/sciC4AT6HAKgLCSH2lbpR/c=
    golang.org/x/[email protected] h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
    golang.org/x/[email protected] h1:6bJEg2w2kUHWlfdJaESYsmNfI1LKAZQi6zCa7LUn7eI=
    golang.org/x/[email protected] h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
    honnef.co/go/[email protected] h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
    mvdan.cc/[email protected] h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.23.0

go env

not relevant

What did you do?

I have a text file like this, where | represents the cursor position:

package main

func main() {
	foobar := []int{1, 2, 3}
	if len(foo|
}

What did you see happen?

I invoked completion (the LSP action is textDocument/completion) and got zero results.

I also used the gopls rpc trace log to verify that gopls got the request and was sending back zero items, so it's not related to some editor integration issue.

What did you expect to see?

I want to see foobar as a suggested completion (probably the only one).

Here are some similar situations where foobar is the suggested completion:

package main

func main() {
	foobar := []int{1, 2, 3}
	foo|
}
package main

func main() {
	foobar := []int{1, 2, 3}
	len(foo|
}
package main

func main() {
	foobar := []int{1, 2, 3}
	if foo|
}
package main

func main() {
	foobar := []int{1, 2, 3}
	if len(foo|)
}

Editor and settings

No response

Logs

The completion trace request/response looks like this:

[Trace - 11:52:32.791 AM] Sending request 'textDocument/completion - (22)'.
Params: {"position":{"character":12,"line":8},"textDocument":{"uri":"file:\/\/\/..path elided...\/x\/x.go"}}


[Trace - 11:52:32.792 AM] Received response 'textDocument/completion - (22)' in 0ms.
Result: {"isIncomplete":true,"items":[]}
@cespare cespare 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, 2024
@gopherbot gopherbot added this to the Unreleased milestone Sep 16, 2024
@adonovan adonovan added the gopls/completion Issues related to auto-completion in gopls. label Sep 16, 2024
@findleyr
Copy link
Contributor

Thanks, we'll investigate. These may be due to poor parser recovery.

@findleyr findleyr modified the milestones: Unreleased, gopls/v0.18.0 Sep 25, 2024
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

5 participants