Skip to content

Instantly share code, notes, and snippets.

@gonzaloserrano
Created November 23, 2016 10:05
Show Gist options
  • Save gonzaloserrano/f2782423df5892194aa1f38649c50400 to your computer and use it in GitHub Desktop.
Save gonzaloserrano/f2782423df5892194aa1f38649c50400 to your computer and use it in GitHub Desktop.
" golang {
" vim-go
"let g:go_golint_bin = "golint"
let g:go_list_type = "quickfix"
"let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
"let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
" c-@ === c-space :-O
au FileType go nmap <c-@> :GoCoverageToggle<CR>
"au FileType go nmap <c-b> :GoBuild<CR>
autocmd FileType go nmap <c-b> :<C-u>call <SID>build_go_files()<CR>
" let g:go_metalinter_autosave = 1
" syntastic shit on-save {}
let g:go_fmt_command = "goimports"
let g:go_fmt_fail_silently = 1
let g:go_fmt_autosave = 1
let g:syntastic_go_checkers = ['gofmt', 'go']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
let g:go_list_type = "quickfix"
"}
let g:go_highlight_build_constraints = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_operators = 1
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_generate_tags = 1
let g:go_term_enabled = 1
" autoimport ftw
" go-def
" if 1, then godeps are included
let g:go_autodetect_gopath = 1
au FileType go nmap <c-]> <Plug>(go-def)
"au FileType go nmap <c-a> <Plug>(go-def-tab)
au FileType go nmap <c-a> :GoAlternate<CR>
autocmd FileType go set noexpandtab
autocmd FileType go set nolist
" default: ['vet', 'golint', 'errcheck']
" gotype does not work with non-installed packages https://github.com/alecthomas/gometalinter/issues/40
let g:go_metalinter_deadline = '20s'
let g:go_metalinter_enabled = ['golint', 'vetshadow', 'errcheck', 'ineffassign', 'vet', 'goimports', 'defercheck', 'aligncheck', 'dupl', 'gofmt', 'varcheck', 'gocyclo', 'testify', 'structcheck', 'deadcode']
" build_go_files is a custom function that builds or compiles the test file.
" It calls :GoBuild if its a Go file, or :GoTestCompile if it's a test file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#cmd#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment