How to Configure Vim as Your Golang IDE
I use Vim massively as my main IDE, and my vimrc file can be found here.
This article presumes that you have already configured Vim as your code editor basically.
Okay, let's get started by installing
fatih/vim-go plugin with your favorite vim plugin manager.
If you have Golang installed correctly on your machine, you will be able to run
:GoInstallBinaries after installing the above plugin.
After that, install coc.nvim plugin, which is a great language server for Vim.
Now, you will need a coc.nvim extension called
coc-go, which will serve as your golang language server.
It can be done by this command:
:CocInstall coc-go coc-json.
You can install some other language server extensions along with
The next step is to configure the installed plugins properly. You can do it just by adding below scripts to your vimrc file:
1" disable all linters as that is taken care of by coc.nvim 2let g:go_diagnostics_enabled = 0 3let g:go_metalinter_enabled =  4 5" don't jump to errors after metalinter is invoked 6let g:go_jump_to_error = 0 7 8" run go imports on file save 9let g:go_fmt_command = "goimports" 10 11" automatically highlight variable your cursor is on 12let g:go_auto_sameids = 0 13" for syntax highlighting 14let g:go_highlight_types = 1 15let g:go_highlight_fields = 1 16let g:go_highlight_functions = 1 17let g:go_highlight_function_calls = 1 18let g:go_highlight_operators = 1 19let g:go_highlight_extra_types = 1 20let g:go_highlight_build_constraints = 1 21let g:go_highlight_generate_tags = 1
K will show documentation for every func you want to know about.
And that's pretty much it. Try and edit some
go files with your awesome IDE.