-
Notifications
You must be signed in to change notification settings - Fork 657
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
[WIP] import declaration autocomplete #332
Conversation
Alright now it works, autocomplete is functioning, I'm gonna just polish it up. |
The plugins will need an update as well. I'll also take a look at vendoring/gb. edit: never mind plugins are fine, I was making a mistake. |
That's a really bad joke. Aside from that I see some bugs, the import doesn't return the correct length of the partial in some cases. That's a second argument form |
Okay, the problem with partial length seems to be the following. If I do autocompletion here: The returned length of the partial is: |
Got it, i'll fix those issues. |
@nsf why are |
Because it came out of my OOP damaged brain. Yes you can make it a method, or a function. Doesn't matter. |
@nsf All I have left to do are completing vendoring and gb. or should that be in another PR? I'll work on the rest of it tomorrow, I gotta do some homework now. And I'm still not sure about the trailing |
When inside a import declaration, a new bool field decl_import in cursor_context is set to true.
Yea after thinking about it a bit more, and using it, I think its worth adding the trailing |
Ah screw it, i'm gonna just do it recursively, I agree with you, I think it'll be much better. LiteIDE actually does it recursively as well. |
Alright, its recursive now. its not slow at all. i'm so confused now why I didn't like it when I first implemented it like this, sigh. Much better now... |
Previous commit detected the import declaration. This one implements returning import candidates. This commit closes #257
Okay, I'm merging it, I think it's in good enough shape to be merged in. |
It definitely works with godit and with vim out of the box. My own sublime text 3 plugin fails to handle it properly. Because it ignores returned partial length and just goes back to last word. Will see if I can fix it. Also in emacs company-mode doesn't work at all in string literals for some reason. Oh, I see: https://github.com/nsf/gocode/blob/master/emacs-company/company-go.el#L191 I guess we'll have to remove that line maybe one day. |
@nhooyr Thanks for the contribution. It's a nice addition to gocode. |
It also seems to be somewhat crash-happy:
|
@dominikh Judging by the stack trace, it probably existed for years there. |
@dominikh fixed |
@nsf you're welcome |
This closes issue #257. Work in progress right now.
Detection of being inside an import statement is done. Here is a testing file.
I just need to take cc.partial and return all import paths that match.