dotfiles/vim/after/ftplugin/go.vim

59 lines
2.0 KiB
VimL

nmap <leader>gb :GoBuild<cr>
nmap <leader>gc :GoCallers<cr>
nmap <leader>gi :GoImplements<cr>
nmap <leader>^ :GoAlternate<cr>
nmap <leader>gk :GoDocBrowser<cr>
nmap <leader>gd :GoDecls<cr>
nmap <leader>gD :GoDeclsDir<cr>
nmap <leader>gv <esc>:vsplit<bar>:GoAlternate!<cr>
nmap <leader>gs <esc>:split<bar>:GoAlternate!<cr>
nmap <leader>gt <esc>:w <bar> :GoTest<cr>
nmap <leader>gf <esc>:w <bar> :GoTestFunc<cr>
nmap <leader>gat <esc>:GoAddTags<cr>
nmap <leader>grt <esc>:GoRemoveTags<cr>
nnoremap <silent> dr :GoDebugBreakpoint<cr>
nnoremap <silent> d! :GoDebugStart<cr>
nnoremap <silent> dc :GoDebugContinue<cr>
nnoremap <silent> dq :GoDebugStop<cr>
nnoremap <silent> dn :GoDebugNext<cr>
nnoremap <silent> ds :GoDebugStep<cr>
" Vim-Go configuration:
let g:go_fmt_autosave = 0
" Vim-Go seems to handle fix-on-save better than ALE:
let g:go_imports_autosave = 1
let g:go_auto_sameids = 0
let g:go_auto_type_info = 0
let g:go_info_mode = 'gopls'
let g:go_highlight_functions = 1
let g:go_term_enabled = 0
let g:go_term_close_on_exit = 0
let g:go_gopls_analyses = {
\ 'composites': v:false,
\ 'unusedparams': v:true,
\ 'unusedresult': v:true,
\ 'shadow': v:true,
\ }
let g:go_fmt_options = {
\ 'goimports': '-local github.com/sensiblecodeio/cantabular',
\ }
autocmd BufNewFile,BufRead *.go nmap <silent> <leader>g6 :GoAlternate!<cr>
iabbrev fmtpl fmt.Println("")<esc>hi
iabbrev fmtpf fmt.Printf("\n")<esc>3hi
iabbrev mk make([]MyType, 0)<esc>9h
iabbrev wr w http.ResponseWriter, r *http.Request
iabbrev httph http.Handler
iabbrev httphf http.HandlerFunc
iabbrev fttt <ESC>ccfunc TestSomething(t *testing.T) {<cr>}<esc>k9l
iabbrev ttt t *testing.T
iabbrev errP <esc>ccif err != nil {<cr>panic(err)<cr>}
iabbrev errl <esc>ccif err != nil {<cr>log.Println(err)<cr>}
iabbrev errp <esc>ccif err != nil {<cr>fmt.Println(err)<cr>}
iabbrev errr <esc>ccif err != nil {<cr>return err<cr>}
iabbrev defr <esc>ccdefer func() {<cr><cr>}()<esc>ki
iabbrev []b []byte()<esc>i