Skip to content

x/tools/gopls: autocomplete in import blocks #35877

Closed
@stamblerre

Description

@stamblerre

Activity

added this to the Unreleased milestone on Nov 27, 2019
added
ToolsThis label describes issues relating to any tools in the x/tools repository.
goplsIssues related to the Go language server, gopls.
on Nov 27, 2019
muirdm

muirdm commented on Nov 27, 2019

@muirdm

Is there a use case for this once unimported completions are enabled by default? The only case I can think of is manually correcting an (incorrect) ambiguous import, but even that should be pretty rare.

heschi

heschi commented on Nov 27, 2019

@heschi
Contributor

I agree the justification for this is weak. Maybe if you're exploring an import hierarchy, like you can't remember the exact package name you're looking for but you know what repo it was in?

stamblerre

stamblerre commented on Nov 27, 2019

@stamblerre
ContributorAuthor

@heschik: That's what I was thinking. Definitely not pressing, but I thought it wasn't a bad idea.

modified the milestones: Unreleased, gopls unplanned on Dec 4, 2019
nbaztec

nbaztec commented on Dec 20, 2019

@nbaztec

I can try to take a look into this one, if someone can point me in the right direction so as where to take a look. Thanks!

We too have long import names, of which sometimes only a part is valid, eg: github.com/foo/bar/my-super-valid-name/v1/lib/http and an autocompletion would certainly be of help

muirdm

muirdm commented on Dec 20, 2019

@muirdm

Another not-mutually-exclusive option is to make unimported package name completion match against the full package path instead of just the package name (i.e. completing package names in the code, not in import specs). Using your example path, the user could type supervalid<> to see unimported packages whose path fuzzily matches "supervalid", or supervalidhttp<> to complete straight to the desired package. This way the user can explore things without resorting to manually futzing with the import spec.

19 remaining items

gopherbot

gopherbot commented on Aug 27, 2020

@gopherbot
Contributor

Change https://golang.org/cl/251086 mentions this issue: internal/lsp/cache: don't invalidate metadata for new invalid imports

muirdm

muirdm commented on Aug 27, 2020

@muirdm

we don't really know if the package path was valid until after we've loaded it

Ah, okay.

Maybe it is worth it to do a simple/fast go list -find <pkg> call on the modified import to first see if it exists? Additionally, if it is already a "known" package path we could skip the additional "go list -find" call and proceed with the full metadata refresh.

stamblerre

stamblerre commented on Aug 27, 2020

@stamblerre
ContributorAuthor

it is already a "known" package path we could skip the additional "go list -find" call and proceed with the full metadata refresh.

Oh that's a great suggestion - let me try it out. We can also detect if the change is on-disk or not, so we can avoid a ton of go list calls when a user changes branches.

stamblerre

stamblerre commented on Aug 27, 2020

@stamblerre
ContributorAuthor

Ah, actually unfortunately, I don't think we'll be able to do that. I completely forgot that go list might download things, so any invalid package path will take go list a long time, and we can't afford to do that while a user types.

stamblerre

stamblerre commented on Aug 27, 2020

@stamblerre
ContributorAuthor

We may be able to use known packages to see if the user is typing a package path within the main module, but that may be error prone. Something to consider in a follow-up.

stamblerre

stamblerre commented on Aug 31, 2020

@stamblerre
ContributorAuthor

@heschik has suggested that we might try loading with GOPROXY=off by default so that the package.Loads are not prohibitively slow. I think a lot of our logic will have to change if #40728 is accepted, so I'd say that it's not worth making any changes until we know what the behavior of go list will be like in 1.16. Then, we make any necessary changes in a cohesive way.

heschi

heschi commented on Sep 1, 2020

@heschi
Contributor

For the record, I think the go mod tidy code lens is also getting involved.

dandua98

dandua98 commented on Sep 12, 2020

@dandua98

@stamblerre should we close this issue and open new issues for import label and cursor placement? I think it would make it easy to track those bugs.

self-assigned this
on Sep 12, 2020
gopherbot

gopherbot commented on Sep 17, 2020

@gopherbot
Contributor

Change https://golang.org/cl/255837 mentions this issue: internal/lsp/source/completion: improve import suggestion labels

locked and limited conversation to collaborators on Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nbaztec@stamblerre@gopherbot@muirdm@heschi

        Issue actions

          x/tools/gopls: autocomplete in import blocks · Issue #35877 · golang/go