-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: providing incomplete completions #35406
Comments
Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here. |
Change https://golang.org/cl/205737 mentions this issue: |
Thanks for filing this! Just uploaded CL 205737, which you can patch into your To install: |
Here are the logs with the cherry-picked patch: vim_channel_log_20191106_1828_25_XQv6GAXO981I.txt |
Oh, I think I understand what's happening with the logs - |
Expanding on my theory from slack, I think this might just be a cgo problem. If you can build the cgo package, then files that use cgo aren't part of the package because they are replaced by generated files (so they don't work for completion or code navigation). If you can't build the package (because you are missing the C headers), then the preprocessing fails and the source files are type checked directly, so things work for the most part. @sbromberger you should be able to test this theory by changing something to break the cgo build for that package (e.g. remove the mpi.h header). Restart gopls and then try completing again. |
It is a cgo problem, but it's a strange one. That is, the presence of this environment variable:
causes the incomplete behavior. When I This is likely due to the fact that that var is required for the package to work, and lends further support to @muirdm's theory. |
That said: is there a workaround for this? My code is simply a wrapper around the C; it's designed to expose the equivalent Go functions. An example:
and
Could it be as simple as checking to see if the file is cgo-related, and if so, type check against the source directly? |
Unfortunately cgo is not really supported yet in gopls. See #32898 (this issue can probably be closed as a dupe). There is a workaround patch in #32898 (comment). |
After some more consideration, it seems like this should work fine. I think the problem is the completion fails because it can't find the documentation for the cgo package's members. This probably has to do with the generated cgo file swaperoo. Anyway, an easy workaround is to disable documentation by setting the gopls config flag "completionDocumentation" to false. |
Change https://golang.org/cl/205862 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release? Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
vim version
With govim, the minimal vimrc, and gopls master installed, attempted to complete an
mpi
command following thempi.Start()
line:I typed in
mpi.
and then hit^x^o
to perform a govim autocomplete. The only results returned wereByte.String
,Complex.String
, andDouble.String
.What did you expect to see?
Other options including
mpi.Stop
What did you see instead?
See above.
Log files attached.
Also note: problem manifests using ALE as well.
gopls_log_20191106_1300_53_965670529.txt
govim_log_20191106_1300_53_952147754.txt
vim_channel_log_20191106_1300_53_hIB6mB1hoOFX.txt
The text was updated successfully, but these errors were encountered: