-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: auto-completion not listing values from unimported packages #57939
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
Comments
Hi @dppascual, thank you for the report. I think I know what this is. The unimported completion cache is built asynchronously in the background. If you added the v1 package recently, it will not show up in unimported completion. If you restart gopls, you should get unimported completion for this package. Can you confirm? Assuming that works, there is still a UX problem here: gopls knows that metadata has been invalidated, and so should invalidate the unimported completion cache eagerly. |
Hi @findleyr, thanks for your reply. I've just created a new package and after gopls is restarted, values from the recently created package are shown as candidates in the completions suggestions pop up. On the other hand, if I start typing the name of any exported value (function, type, ...) with no package name explicitly indicated as a prefix; gopls only reports suggestions from imported packages or std library packages. It seems that if we want completion suggestions from unimported packages, gopls forces us to
Do you know if there is any configurable option to tell gopls that I want all packages from my current workspace to be taken into account when an autocompletion operation is performed? |
Thanks for checking @dppascual
Agree that this is a UX bug - users shouldn't require to restart gopls. I marked this issue as NeedsInvestigation, but @findleyr, if you know how to fix this, please relabel it accordingly.
I think this needs to be tracked as a separate feature request. I am not sure if gopls currently suggests std library package's exported functions or types before importing the package or prefixing with the package name. (I tried some and it was never successful). In theory, I see commonality with the workspace symbol search - as long as there is enough completion budget and no other candidates from imported packages is found. |
Hi @hyangah, you are right, gopls does not suggest std library package's exported functions of types if the mentioned package is not imported or prefixed. I didn't realize the package from the std library was already imported when testing.
I've been continue testing how gopls resolves values from packages recently created and found an unexpected behaviour during autocompletion procedure. Once gopls is restarted, packages recently created are taking account by gopls, but not always the server sends suggestions from such package, even when there is an exact-match. I attach a video (compressed at 720p because at 1080p was too big) below where you can see better what I explain before. The type unexported_package.mov**Logs from gopls **
|
Using VSCode with gopls v0.11.0, I confirm the problem reported in this issue. Specifically, I used a |
gopls version
go env
What did you do?
Support for autocompletion of unimported packages was introduced in this ticket #31906, but it seems not working, not sure if this feature has been deprecated. When you create a new package and import a value from such package in another one placed in the same workspace, no member is shown in the completions suggestions pop up. Attached a video as an example:
completion_unimported_packages.mov
What did you expect to see?
A list of candidates from unimported packages.
What did you see instead?
No candidates at all until I manually import a package.
Editor and settings
Editor:
Gopls settings:
The text was updated successfully, but these errors were encountered: