Author Avatar

Anuj Verma

0

Share post:

I just love working in Vim and cannot even think of switching to a new editor. If you are also a Vim lover and you use Golang, you must read this post to make sure you have the right setup.

Here is how my vim looks like and yes the look is very simple though powerful.

Following are the most important features which I prefer to have:

  1. Run gofmt and goimports on save
  2. Peek at documentation
  3. Autocomplete
  4. Jump to symbols or functions definitions
  5. Automatic variable type and function signature info
  6. Pretty and lightweight status bar at bottom
  7. Version control information

In order to have all these features integrated in Vim, I used the following plugins:

vim-go development plugin

Installation
git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go
Uninstall
rm -r ~/.vim/pack/plugins/start/vim-go 

Lean and Mean status bar

Install

git clone https://github.com/vim-airline/vim-airline ~/.vim/pack/dist/start/vim-airline

Uninstall

rm -r ~/.vim/pack/dist/start/vim-airline

An awesome Git wrapper

Install

git clone https://github.com/tpope/vim-fugitive.git ~/.vim/pack/dist/start/vim-fugitive 

Uninstall

rm -r ~/.vim/pack/dist/start/vim-fugitive

After installing all the plugins, here is how you can configure ~/.vimrc file:

syntax on

colo pablo

set encoding=utf-8

set fileencoding=utf-8

set number

set shiftwidth=2

" settings specific to Go file types
autocmd Filetype go setlocal tabstop=4 shiftwidth=4 softtabstop=4

filetype plugin indent on

set backspace=indent,eol,start

" vim-go commands
let g:go_fmt_command = "goimports"
let g:go_auto_type_info = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1

I hope you have enjoyed this post and it will be helpful for you to setup your Vim. Please like and share and feel free to comment if you have any suggestions or feedback.

Most common openssl commands
5 simple examples to understand Elasticsearch aggregation

Leave a Reply