Skip to content

x/tools/gopls: lo package is not autocompleted if it's not already imported #60964

Closed
@vikstrous2

Description

@vikstrous2

lo refers to https://github.com/samber/lo
I'm using gopls in vs code

gopls version

gopls -v version
Build info
----------
golang.org/x/tools/gopls v0.12.3
    golang.org/x/tools/[email protected] h1:u0wCI9uvt7mnmri6bFBIaWw1XCN6PN8hKv55Zwd+GbE=
    github.com/BurntSushi/[email protected] h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/[email protected] h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
    github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/[email protected] h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
    golang.org/x/exp/[email protected] h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/[email protected] h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
    golang.org/x/[email protected] h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
    golang.org/x/[email protected] h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
    golang.org/x/[email protected] h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
    golang.org/x/[email protected] h1:OqO0SKgRQpzXVmbHUZc/ropwr82dwTQPJtJ9HHNMy2c=
    golang.org/x/[email protected] h1:A9kONVi4+AnuOr1dopsibH6hLi1Huy54cbeJxnq4vmU=
    honnef.co/go/[email protected] h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc=
    mvdan.cc/[email protected] h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
    mvdan.cc/xurls/[email protected] h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.20.4

go env

Probably not relevant.

What did you do?

Any time I want to use lo, I type lo. or lo<tab> and it never gets auto-imported. I have to resort to typing lo.Map and saving the file to trigger the auto-import.

To repro just create this go.mod file:

module example.com

go 1.20

require (
	github.com/samber/lo v1.38.1 // indirect
	golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
)

and try auto-completing lo in a main.go file.

After importing it successfully once, it seems to eventually start to pop up in suggestions.. but even then it's never first.

It really hurts the usability of this package when you can't get auto-completion without importing it first. I'm pretty sure there's something special about the length of the package name that's causing this because I haven't seen this problem with other packages.

What did you expect to see?

image

What did you see instead?

image

Editor and settings

nothing very relevant in settings.json

  "go.testFlags": ["-v"],
  "go.testEnvVars": { "GODEBUG": "tracebackancestors=5" },
  "gopls": {
    "formatting.gofumpt": true,
  },

Logs

Sorry, I haven't dig into it deeper yet and set up extra logging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/completionIssues related to auto-completion in gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions