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

GoInfo fails silently on systems where gocode -sock=unix fails #996

Closed
blin opened this issue Aug 6, 2016 · 5 comments · Fixed by #1000
Closed

GoInfo fails silently on systems where gocode -sock=unix fails #996

blin opened this issue Aug 6, 2016 · 5 comments · Fixed by #1000

Comments

@blin
Copy link

blin commented Aug 6, 2016

Actual behavior

GoInfo fails silently if gocode -sock=unix fails.

Expected behavior

GoInfo fails with an error message and a suggestion to set something like let g:go_gocode_sock_tcp = 1. let g:go_gocode_sock_tcp = 1 adds -sock=tcp to gocodeCommand's preargs.

Steps to reproduce:

  1. Use bash on ubuntu on windows
  2. Install vim-go
  3. :GoInstallBinaries
  4. Run :GoInfo over any symbol.

Running gocode on bash on ubuntu on windows

$ gocode -sock=unix
dial unix /tmp/gocode-daemon.blin: setsockopt: invalid argument
$ echo $?
1

$ gocode -sock=tcp
$ echo $?
0

Workaround

--- a/autoload/go/complete.vim
+++ b/autoload/go/complete.vim
@@ -76,7 +76,7 @@ function! s:gocodeAutocomplete()

   let filename = s:gocodeCurrentBuffer()
   let result = s:gocodeCommand('autocomplete',
-        \ [s:gocodeCurrentBufferOpt(filename), '-f=vim'],
+        \ [s:gocodeCurrentBufferOpt(filename), '-f=vim', '-sock=tcp'],
         \ [expand('%:p'), go#util#OffsetCursor()])
   call delete(filename)
   return result
@@ -86,7 +86,7 @@ function! go#complete#GetInfo()
   let offset = go#util#OffsetCursor()+1
   let filename = s:gocodeCurrentBuffer()
   let result = s:gocodeCommand('autocomplete',
-        \ [s:gocodeCurrentBufferOpt(filename), '-f=godit'],
+        \ [s:gocodeCurrentBufferOpt(filename), '-f=godit', '-sock=tcp'],
         \ [expand('%:p'), offset])
   call delete(filename)
@fatih
Copy link
Owner

fatih commented Aug 7, 2016

Hi @blin

So this fails on if you use gocode on bash on ubuntu on windows ? I'm not sure why vim-go should fix it? Shouldn't you open this issue for gocode itself ?

@blin
Copy link
Author

blin commented Aug 8, 2016

The main concern that I have is that vim-go fails silently, instead of producing a clear error message. It took me a long time to figure out that something was wrong with gocode, rather than my vim installation or configuration.

Shouldn't you open this issue for gocode itself ?

I should open an issue for BashOnWindows. Still, adding an option to set -sock=tcp on gocode will not introduce a lot of complexity to the code base and will address a real issue.

@fatih
Copy link
Owner

fatih commented Aug 8, 2016

If you give a screenshot or the correct error message I might have a look at it.

@blin
Copy link
Author

blin commented Aug 9, 2016

If you give a screenshot or the correct error message I might have a look at it.

I'm not sure I understood what you wanted, but here you go https://i.imgur.com/tLUbLa8.png .

This is the result of the following change:

--- a/autoload/go/complete.vim
+++ b/autoload/go/complete.vim
@@ -37,6 +37,7 @@ function! s:gocodeCommand(cmd, preargs, args)
   let $GOPATH = old_gopath

   if go#util#ShellError() != 0
+    echoerr "gocode failed:" . result
     return "[\"0\", []]"
   else
     if &encoding != 'utf-8'

Note that error detection is already in place, but the error is never presented to the user.

@fatih
Copy link
Owner

fatih commented Aug 9, 2016

The reason for that is that the autocompletion engine in Vim itself accepts a value. And that's it. You can't go and pass an error to it. And if you try to echo it, it shows it in an unreadable way. I'm adding a setting now where you can customize the socket flag that is passed to gocode. At least you can use that to fix the issue.

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 a pull request may close this issue.

2 participants