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

gocode: add support for experimental gocode #1988

Merged
merged 2 commits into from
Oct 21, 2018
Merged

gocode: add support for experimental gocode #1988

merged 2 commits into from
Oct 21, 2018

Conversation

fatih
Copy link
Owner

@fatih fatih commented Sep 21, 2018

WIP. Somehow gocode-gomod only returns %20 of the time the candidates. To test it you can use gomodifytags repo. First pen gocode-gomod in debug mode to see that it doesn't return any candidates:

gocode-gomod exit
gocode-gomode -s -debug

Clone gomodifytags and play around:

git clone https://github.com/fatih/gomodifytags
cd gomodifytags
vim main.go
// try to complete flag. exported identifiers

This doesn't work always, not sure why.

For more information see: microsoft/vscode-go#1932

@fatih
Copy link
Owner Author

fatih commented Sep 21, 2018

@bhcleek I'm out of town for one week, I'll try to debug it once I'm back. But if you have some spare times, you can also try it out (there is not much code). I posted the instructions. I think it might be due to the Unix socket name, which conflicts when gocode and gocode-gomod runs at the same time? Not sure but could be worth looking at it.

@stamblerre
Copy link
Contributor

@fatih, I'm also happy to take a look at this. It should be pretty similar to the change I made for VSCode. Thank you for starting it off!

@stamblerre
Copy link
Contributor

@fatih, I started looking at this, and it seems to be working ok for me. I don't use Vim often, so I may be making a mistake, but I basically tested it out by starting "gocode -s -debug" and "gocode-gomod -s -debug" and then coding in Vim in one $GOPATH directory and a different directory with a go.mod file. It seemed like the completions were being directed to the right version of gocode in both cases.

The only thing I did notice was that to trigger gocode I had to enter the "C-x C-o" keybinding, whereas there were a few times when autocompletions just popped up on my screen. I would attribute this to some incorrect Vim setting on my part, but it did seem to be ~20% of the time those completions appeared, so I wonder if that's related?

@bhcleek
Copy link
Collaborator

bhcleek commented Sep 26, 2018

@fatih, overall this seems to work really well. One other thing to note, though: it's probably a good idea to also disable g:go_gocode_propose_source while testing to be sure that -source isn't being used to find matches.

Like you and @stamblerre , I did see some instances where autocompletion couldn't find any candidates. It seemed to miss when it all exported identifiers from a package should have been returned (e.g. trying to autocomplete flag.), but it wasn't anywhere near 20% misses for me, and once it started completing identifiers from a package where it had previously missed, I didn't notice anymore misses from that package.

@stamblerre you should always have to use C-x C-o to autocomplete with vim-go. If autocompletion is popping up without that, then either something else is doing it or it's just taking a while for it to pop-up from a previous attempt.

For any readers that may be concerned about running gocode and gocode-mod simultaneously: @stamblerre's fork use a different unix domain socket than mdempsky's thanks to stamblerre/gocode@b960ec2, so it should be safe to run both gocode and gocode-mod simultaneously.

@fatih
Copy link
Owner Author

fatih commented Oct 10, 2018

Paul Jolly shared the following notes:

The one thing to point out with respect to gocode in module mode is that files will have to be saved to disk before completions can work reliably

(or jumping to definitions for that matter)
Reason being, go list needs to see the file for the imports etc to resolve
This is only a short term issue, but it might be worthwhile having the jump-to-definition and completion shortcuts automatically save a file in the meantime (in module mode)

@bhcleek
Copy link
Collaborator

bhcleek commented Oct 10, 2018

Did Paul provide any expectations for how long short term will be?

@myitcv
Copy link

myitcv commented Oct 10, 2018

Did Paul provide any expectations for how long short term will be?

No specific timelines from the tools team for now, no.

Context: https://docs.google.com/document/d/1oEknhf60Cdg9p_i17ESIm3zjTuVK7Adr-lTw78D0Qrc/edit#bookmark=id.ko11cb4rz28i

@bhcleek
Copy link
Collaborator

bhcleek commented Oct 10, 2018

Thanks, @myitcv. Fatih is going to put us in touch next week, and I'll be sure to have reviewed the docs by then.

@bhcleek bhcleek changed the title gocode: add support for experimantal gocode gocode: add support for experimental gocode Oct 18, 2018
@bhcleek bhcleek merged commit 5fffae9 into master Oct 21, 2018
@bhcleek bhcleek deleted the gocode branch October 21, 2018 20:33
@bhcleek bhcleek removed the wip label Oct 21, 2018
@thepudds thepudds mentioned this pull request Feb 16, 2019
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants