Budi Dharmawan


Brown eyes, deuteranomalic. Oh the irony.

My Vim Broke — Or My Go?

For the past three days, I have a problem with my Vim. My MacVim, to be precise. I have been working on some Golang projects lately, and I use vim-go for quite some time. For reasons unknown — okay, I forgot what I did — it spewed out an error saying that goimports does not support srcdir when I tried to save a file.

At that very first occurrence, I decided: I will not Google this shit.

I took notes for the steps I did and hoped I don’t get stuck and succumb. As it turns out, by some great luck, it’s fixed. Here’s what happened.

TL;DR → I re-installed some stuff using different configurations.

The error popped out. MacVim forced me to tap a key after the error shows up and I can get to edit again. I checked my .vimrc… nothing seems out of context. I checked my go env, all looks good. Strange.

I remember I installed go from the official package, so my $GOROOT is pointed to /usr/local/go. Oh well, it’s been long since I updated to 1.5 anyway, let’s just demolish them and try installing them via Homebrew. So I did. I removed usr/local/go and execute brew install go. Hello, 1.6.2!

MacVim still broken. Of course.

After I read some :help vim-go, I tried :GoUpdateBinaries and let it install things to my $GOPATH/bin. Error message still persists. At that time I got my iTerm opened and I just want to double check my environment variables on my .zshrc.

So I fired up vimhooray muscle memory.

Just when I opened my session menu, I thought hey, “Hold on a second. Let’s try do some Go stuff from terminal vim”. Shocking truth: everything works. The troubled goimports, :GoDef, everything works.

For the next four days, I did my daily tasks using terminal vim. I really have nothing to complain except for its rendering time.

Four days. Slow renders. I miss MacVim.

I tried switching back and used gofmt instead of goimports. It works, but no imports automation. Sucks.

I tried re-installing my MacVim with system Ruby, Python 2, etc. Back to basic. No Python 3, lua-jit, etc. Removed not-that-much-used plugins… no luck. Then I realized, gofmt is installed in /usr/local/go/bin and it works, but my $GOPATH/bin didn’t get picked up.

I set my$GOBIN, then. I pointed my $GOBIN to /usr/local/go/bin and run :GoUpdateBinaries.

Voila! MacVim now works with vim-go and all its binaries installed on /usr/local/go/bin.


I’m not really sure I fixed it because I:

… but I fixed it without Googling. It takes more time, for sure, but I think I’ll do this kind of practice every once in a while. I don’t want to be that one guy who just so good at querying questions. I want to fix things.