volgar1x / vim-gocode

A Go bundle for Vundle or Pathogen
237 stars 34 forks source link

Installation on OS X #2

Open jaytaylor opened 10 years ago

jaytaylor commented 10 years ago

The install lists pathogen as "todo". Is it not yet ready?

When I try to run :CurPkg, I get:

You are not in a go package

volgar1x commented 10 years ago

You successfully installed vim-gocode through pathogen, it seems to be a bug at first sight. Can you run the command

:echo ReadLink(g:gocode_path)

And then

:echo ReadLink(@%)

And tell me the output?

jaytaylor commented 10 years ago

:echo ReadLink(g:gocode_path)

E121: Undefined variable: g:gocode_path E116: Invalid arguments for function ReadLink(g:gocode_path) E15: Invalid expression: ReadLink(g:gocode_path)

:echo ReadLink(@%)

readlink: illegal option -- f usage: readlink [-n] [file ...]

Other miscellaneous info: this is on a MacBook Air with a fresh install of OS-X 10.8.4 and a case-sensitive filesystem.

volgar1x commented 10 years ago

I haven't tested this plugin on other system than Linux. Could you please edit the ReadLink function inside vim-gocode/ftplugin/go/pkg.vim to make it works (ie get the full path) on your OS ? Other question : have you installed Go? VIM can't echo any g:gocode_path variable which is a sign that 'go env GOPATH' didn't work.

jaytaylor commented 10 years ago

I will update the readlink fn. go is definitely installed with good GOPATH and GOROOT env vars.

Hopefully together we can get this to be compatible with Mac.

Best, Jay

On Sep 2, 2013, at 11:15 PM, Blackrush notifications@github.com wrote:

I haven't tested this plugin on other system than Linux. Could you please edit the ReadLink function inside vim-gocode/ftplugin/go/pkg.vim to make it works (ie get the full path) on your OS ? Other question : have you installed Go? VIM can't echo any g:gocode_path variable which is a sign that 'go env GOPATH' didn't work.

— Reply to this email directly or view it on GitHub.

volgar1x commented 10 years ago

I found a good starting point to use readlink on OS X : http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac

macb commented 10 years ago

Might I recommend making a note that it currently doesn't work on osx? Spent a while beating myself over the head until I checked the issues.

macb commented 10 years ago

Also, as a solution for future mac users:

brew install coreutils ln /usr/local/bin/greadlink /usr/local/bin/readlink

maybe re-source profile. (I had to get which readlink to return the correct path)

JohnAmican commented 10 years ago

@seanbr nice job, gave a solution an hour before I went looking for it!

JohnAmican commented 10 years ago

Also FYI things start breaking if there are spaces in folder names. I'll open up an issue about it later.

volgar1x commented 10 years ago

I renamed this issue "Installation on OS X", created a wiki article and linked it in the README. Tell me if I have done anything wrong.

oguzbilgic commented 10 years ago

I get the same You are not in a go package error on both OS X and ubuntu 13.

volgar1x commented 10 years ago

Can you please execute the commands that I previously wrote?

bilby91 commented 10 years ago

I'm having the same issue, already executed both commands and no luck.

volgar1x commented 10 years ago

What is exactly the output ?

bilby91 commented 10 years ago

:echo ReadLink(g:gocode_path)

E121: Undefined variable: g:gocode_path
E116: Invalid arguments for function ReadLink(g:gocode_path)
E15: Invalid expression: ReadLink(g:gocode_path) 

:echo ReadLink(@%)

readlink: illegal option -- f
usage: readlink [-n] [file ...] 
volgar1x commented 10 years ago

Have you install coreutils and make the greadlink redirection to readlink ?

bilby91 commented 10 years ago

Yes, installed coreutils through brew and made the symlink.

volgar1x commented 10 years ago

Try readlink -f . in a Terminal and tell me the output

bilby91 commented 10 years ago

Same output

readlink: illegal option -- f
usage: readlink [-n] [file ...] 
volgar1x commented 10 years ago

vim-gocode needs some OS X integration, wait until someone patch this problem or make it yourself (I don't own a Mac)

bilby91 commented 10 years ago

Can your provide me any orientation on where the issue could be.

Thanks for the help either way!

volgar1x commented 10 years ago

You can look here https://github.com/Blackrush/vim-gocode/blob/master/ftplugin/go/pkg.vim#L10 as a first step

macb commented 10 years ago

what is the output of:

which brew which readlink

It seems to me that you are using osx's readlink still. I've installed vim-gocode 3 times now on seperate OSX installs and after doing the 'brew install coreutils' and linking greadlink into my path (ahead of osx readlink) it's been perfect.

My guess is your brew bin path (most likely /usr/local/bin) is at the end of your path.

bilby91 commented 10 years ago
which brew
/usr/local/bin/brew

which readlink
/usr/bin/readlink
macb commented 10 years ago

Yep, that's your issue. You need to make sure your home brew path /usr/local/bin is the first entry into your path. This way anything that replaces an osx default will be used instead of the osx one.

Do this by editing your bash profile, bash rc, or system profile to something that contains:

export PATH=/usr/local/bin:$PATH

bilby91 commented 10 years ago

I changed my .zshrc file to fix the problem with the order of paths. Now my output is correct.

which readlink
/usr/local/bin/readlink

I'm still having the same issue. Can it be an issue with my GOPATH being setup'd incorrectly? It seems correct to me.

volgar1x commented 10 years ago

What does output, in VIM, :!go env GOPATH ?

bilby91 commented 10 years ago

It shows me the correct GOPATH.

ghost commented 10 years ago

I solved the problem by installing brew install coreutils and replacing readlink -f with greadlink -f in -> https://github.com/Blackrush/vim-gocode/blob/master/ftplugin/go/pkg.vim#L10

Previously I tried ln -s /usr/local/bin/greadlink /usr/local/bin/readlink but it didn't worked for me.

volgar1x commented 10 years ago

does function ReadLink has to be edited to include OS specific behavior ?

pengux commented 10 years ago

I followed the instructions to install on Mac OS X, but when I try completion with CTRL X + CTRL O, it gives the following error:

Omni completion (^O^N^P) Pattern not found

What am I missing?

volgar1x commented 10 years ago

Have you installed gocode ? Do you have it in your PATH ?

pengux commented 10 years ago

Ah sorry. So I just did a "go build" in gocode folder and copied the generated binary to /usr/local/bin. Is it correct?

volgar1x commented 10 years ago

A simple go get github.com/nsf/gocode worked perfectly for me

UPDATE

f93b0a750 adds some instruction

cynipe commented 10 years ago

this is why readlink does not work properly: http://superuser.com/questions/31353/path-in-vim-doesnt-match-terminal