paulgorman.org/technical

Go Development in Vim with the vim-go Plungin

(October 2019)

The Vim editor can be a production Go development environment with the vim-go plugin.

Initial set up:

🐚 ~ $ mkdir -p .vim/pack/plugins/start
🐚 ~ $ cd .vim/pack/plugins/start
🐚 ~ $ git clone https://github.com/fatih/vim-go
🐚 ~ $ sudo vi
:helptags ALL
:q
🐚 ~ $ vi
:GoInstallBinaries

Add to .vimrc:

" vim-go stuff:
map <C-n> :cnext<CR>
map <C-m> :cprevious<CR>
nnoremap <leader>a :cclose<CR>
let g:go_fmt_autosave = 1
let g:go_fmt_command = "goimports"
autocmd FileType go nmap <leader>b  <Plug>(go-build)
autocmd FileType go nmap <leader>d  <Plug>(go-doc)
autocmd FileType go nmap <leader>r  <Plug>(go-run)

Help:

🐚 ~ $ vi -R /home/paulgorman/.vim/pack/plugins/start/vim-go/README.md
:h vim-go

https://github.com/fatih/vim-go/wiki

Commonly-used functions:

:GoDoc
:GoFmt
:GoImports
:GoLint
:GoDef
:GoRun
:GoBuild
:GoInstall
:GoTest