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: autocomplete in import blocks #35877

Open
stamblerre opened this issue Nov 27, 2019 · 11 comments
Open

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

stamblerre opened this issue Nov 27, 2019 · 11 comments

Comments

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Nov 27, 2019

Suggested in microsoft/vscode-go#2918.

@muirdm

This comment has been minimized.

Copy link

@muirdm muirdm commented Nov 27, 2019

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.

@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Nov 27, 2019

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

This comment has been minimized.

Copy link
Contributor Author

@stamblerre stamblerre commented Nov 27, 2019

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

@nbaztec

This comment has been minimized.

Copy link

@nbaztec nbaztec commented Dec 20, 2019

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

This comment has been minimized.

Copy link

@muirdm muirdm commented Dec 20, 2019

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.

@stamblerre

This comment has been minimized.

Copy link
Contributor Author

@stamblerre stamblerre commented Dec 20, 2019

Thanks, @nbaztec! The code for completion can be found here, but I think you'd be specifically interested in unimported completions, which are done here.

@nbaztec

This comment has been minimized.

Copy link

@nbaztec nbaztec commented Dec 21, 2019

Thanks a bunch @stamblerre !
I tried to look into some docs on how to best debug/test gopls and right now the only way I'm aware of is to compile a copy and try it out in vs-code. Is there any way I can perhaps use a debugger/delve while testing? That would help me a ton!

@nbaztec

This comment has been minimized.

Copy link

@nbaztec nbaztec commented Dec 22, 2019

Ok I tried asking some questions and figured out some code, however would really appreciate some help in how can I debug the application, via tests. Documentation seems to be missing on how to write my expectations for the following case:

package foo

import "fm{}"  // trigger suggestions

Any direction is highly appreciated, thanks!

@stamblerre

This comment has been minimized.

Copy link
Contributor Author

@stamblerre stamblerre commented Dec 23, 2019

@nbaztec: I saw that you got some guidance on Slack - were you able to figure out the issue?

@nbaztec

This comment has been minimized.

Copy link

@nbaztec nbaztec commented Dec 27, 2019

Yes, I happened to figure out the above. Also, is a completion snippet the only way to replace the text on the current line?
Eg: replace import "fm_" directly by fmt?

@stamblerre

This comment has been minimized.

Copy link
Contributor Author

@stamblerre stamblerre commented Dec 27, 2019

Completion items have a TextEdit field that indicates what should be filled in for a completion item (see here for more details).

@stamblerre stamblerre modified the milestones: gopls unplanned, gopls completion Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.