36 comments

[ 3.3 ms ] story [ 79.5 ms ] thread
It's not really a full setup, it's just a vim plugin.
I've been using vim-go for about one year now. The combination of vim-go, gofmt and YouCompleteMe is all you need for a perfect Go setup. Thanks to Fatih and Val!
goimports is so dang nice, too. If for some reason you overlooked it on the README:

Enable goimports to automatically insert import paths instead of gofmt:

let g:go_fmt_command = "goimports"

Yes I do use goimports. Also very useful.
I suggest you try https://github.com/garyburd/go-explorer too! (From creator of godoc.org.) In short words, it's godoc with hyperlinks (in your vim). I use it both for doc (so I don't have to switch to browser), and for project-wide navigation.

    :GeDoc net/http         --> opens a "gedoc" split
    :GeDoc fmt Printf       --> + jump to specific identifier
                                (note: full TAB-completion)
    :GeDoc \html_template   --> + resolve import alias like:
                                import html_template "html/template"
    zM                --> fold all
    zo                --> unfold current
    zc                --> fold current
    Ctrl-]            --> "follow link under cursor"
    Ctrl-A            --> show all! (i.e. unexported too)
You're welcome! It's my pleasure. I'm really happy to see people writing Go in a more productive environment.
YouCompleteMe crashes frequently on my mac. I can't find a solution. Does someone here have a solution?
I switched from YCM to neocomplete[1] a few months ago and haven't looked back, performance is much better. I'm on Arch and never really had crashes with YCM, but if the crashes are performance related it might help.

[1] https://github.com/Shougo/neocomplete.vim

I need to use YouCompleteMe for C++ autocomplete.
(comment deleted)
Can someone recommend a set of Emacs libraries that works as well as this? I'm about to embark on a real project in go.
I use go-mode, go-eldoc, gotest, company-go, and go-projectile (along with non-go-specific packages like flycheck, which has built-in go support).
It's really nice, but lack specific feature of auto-importing packages while typing. Like, if you type `fmt.` and package is not imported yet, you'll not see any completions.

So, I've implemented it a while ago in separate coding-helping plugin, see the gif: https://github.com/reconquest/vim-pythonx#autoimport

UPD: also, some gifs, showing how coding routine I believe should be done (Golang taken as example): https://github.com/reconquest/snippets#let-me-show. Type less, get more.

It does, just not by default, and only on save – not while typing.

> Enable goimports to automatically insert import paths instead of gofmt:

> let g:go_fmt_command = "goimports"

Yeah, only on save.

It's deal breaker for me, I want to see completions immediately, not by entering `fmt.`, saving file, backspacing, re-entering `.`.

On the flipside, what implements this functionality you speak of? I ask, because you mention it being a deal breaker for vim-go, so i'm curious what you currently use?
I'm using vim-go, I just implemented autoimport functionality on top of it.
Why? I code Go in Vim every day, and I think goimports is perfect. I don't even think about the import ( ... ) block at the top - I just use what packages I want, save my code, and let the machine take care of the imports. If you have your GOPATH set up properly, it works 100% of the time.
Looks like I was not clear enough. goimports works perfectly, but only on buffer save event (or by manual trigger).

Take an example, start from scratch:

  package main
  
  func main() {
    fmt|
  }
Cursor is at |, and when I type ., I immediatelly have fmt package imported and see completion menu for fmt package (without leaving insert mode or saving file, just by typing dot).

Out of the box vim-go doesn't provide that.

Ah, you want the full package exports available for autocomplete? Have you found a way to do that?
I think slightly differently. I don't think I import enough packages for "save file after first usage" to become a deal breaker.
Author here. Vim doesn't have type by completion support, however it imho has completion, but it needs to be triggered manually with a key shortcut(such as C-X C-O). Plugins like YCM changes this behavior to on the fly completion.

For gifs, I have couple of screencasts already (all in Wiki: https://github.com/fatih/vim-go/wiki/Screencasts), but yeah we could definitely add a GIF, but my time is limited for this kind of stuff :)

I am not a vim user and I've been using IntelliJ IDEA to code in GoLang for about an year now and I find it extremely powerful. It is powered using the GoLang IntelliJ plugin : https://github.com/go-lang-plugin-org/go-lang-idea-plugin

It provides : 1) Error Highlighting, 2) Auto Completion, 3) Click-to-Navigate, 4) Auto Formatting, 5) Auto Importing, among other features.

This. I've seen my teammates try other Go IDE integrations but this just beats the pants off all of them and our whole team wound up standardizing on it.

It combines well with Tim Pope's dispatch plugin for doing an async 'go build' or 'go test' while you code:

https://github.com/tpope/vim-dispatch

I still swear by LiteIDE. If you write go, you should try it, you will not be disappointed.