" go " vim-go " run :GoBuild or :GoTestCompile based on the go file function! s:build_go_files() let l:file = expand('%') if l:file =~# '^\f\+_test\.go$' call go#test#Test(0, 1) elseif l:file =~# '^\f\+\.go$' call go#cmd#Build(0) endif endfunction let g:go_list_type = "quickfix" let g:go_fmt_command = "goimports" let g:go_fmt_fail_silently = 1 let g:go_highlight_types = 1 let g:go_highlight_fields = 1 let g:go_highlight_functions = 1 let g:go_highlight_methods = 1 let g:go_highlight_operators = 1 let g:go_highlight_build_constraints = 1 let g:go_highlight_structs = 1 let g:go_highlight_generate_tags = 1 let g:go_highlight_space_tab_error = 0 let g:go_highlight_array_whitespace_error = 0 let g:go_highlight_trailing_whitespace_error = 0 let g:go_highlight_extra_types = 1 autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 augroup completion_preview_close autocmd! if v:version > 703 || v:version == 703 && has('patch598') autocmd CompleteDone * if !&previewwindow && &completeopt =~ 'preview' | silent! pclose | endif endif augroup END " for go files augroup go au! au Filetype go command! -bang A call go#alternate#Switch(0, 'edit') au Filetype go command! -bang AV call go#alternate#Switch(0, 'vsplit') au Filetype go command! -bang AS call go#alternate#Switch(0, 'split') au Filetype go command! -bang AT call go#alternate#Switch(0, 'tabe') au FileType go nmap dd (go-def-vertical) au FileType go nmap dv (go-doc-vertical) au FileType go nmap db (go-doc-browser) au FileType go nmap r (go-run) au FileType go nmap t (go-test) au FileType go nmap gt (go-coverage-toggle) au FileType go nmap i (go-info) au FileType go nmap l (go-metalinter) au FileType go nmap :GoDecls au FileType go nmap dr :GoDeclsDir au FileType go imap :GoDecls au FileType go imap dr :GoDeclsDir au FileType go nmap rb :call build_go_files() augroup END "" ale :call extend(g:ale_linters, {"go": [ 'golint', 'go vet' ]})