Vim setup for Go
github.com
github.com
Enable goimports to automatically insert import paths instead of gofmt:
let g:go_fmt_command = "goimports"
: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)It provides : 1) Error Highlighting, 2) Auto Completion, 3) Click-to-Navigate, 4) Auto Formatting, 5) Auto Importing, among other features.
It combines well with Tim Pope's dispatch plugin for doing an async 'go build' or 'go test' while you code:
good alternative : (Dockerfile) Sublime Text 3 for Go
https://github.com/jgautheron/dockerfiles/blob/master/sublim...
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.
> Enable goimports to automatically insert import paths instead of gofmt:
> let g:go_fmt_command = "goimports"
It's deal breaker for me, I want to see completions immediately, not by entering `fmt.`, saving file, backspacing, re-entering `.`.
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.
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 :)