dotfiles/vim/after/ftplugin/go.vim

89 lines
3.0 KiB
VimL
Raw Normal View History

2021-03-18 12:30:30 +00:00
nmap <silent> gvd <Plug>(go-def-vertical)
nmap <silent> gsd <Plug>(go-def-split)
nmap <silent> gvD <Plug>(go-def-type-vertical)
nmap <silent> gsD <Plug>(go-def-type-split)
2021-03-18 08:05:37 +00:00
nmap <silent> <leader>gb :up<bar>:GoBuild<cr>
nmap <silent> <leader>gr :up<bar>:GoRun<cr>
nmap <silent> <leader>gc :GoCallers<cr>
" TODO: if GoInfo returns nothing an [INFO] SUCCESS message is shown.
" But disabling g:go_echo_command_info impacts build and test workflow.
nmap <silent> <leader>gi :GoInfo<cr>
nmap <silent> <leader>gp :GoImplements<cr>
nmap <silent> <leader>ga :GoAlternate<cr>
nmap <silent> <leader>gk :GoDocBrowser<cr>
nmap <silent> <leader>gd :GoDecls<cr>
nmap <silent> <leader>gD :GoDeclsDir<cr>
2021-03-15 15:29:40 +00:00
" mnemonic: match
2021-03-18 08:05:37 +00:00
nmap <silent> <leader>gm :GoSameIds<cr>
2021-01-27 14:32:26 +00:00
2021-03-18 08:05:37 +00:00
nmap <silent> <leader>gv <esc>:vsplit<bar>:GoAlternate!<cr>
nmap <silent> <leader>gs <esc>:split<bar>:GoAlternate!<cr>
nmap <silent> <leader>gt <esc>:up<bar>:GoTest<cr>
nmap <silent> <leader>gf <esc>:up<bar>:GoTestFunc<cr>
nmap <silent> <leader>gat <esc>:GoAddTags<cr>
nmap <silent> <leader>grt <esc>:GoRemoveTags<cr>
nmap <silent> <leader>gec <esc>:up<bar>:GoErrCheck<cr>
2021-01-27 19:17:05 +00:00
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>
2021-03-18 08:05:37 +00:00
" Avoid window positions jumping around when building and testing:
set cmdheight=2
2021-03-09 19:40:10 +00:00
" fzf configuration:
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
2021-03-18 08:05:37 +00:00
\ 'ctrl-s': 'split',
2021-03-09 19:40:10 +00:00
\ 'ctrl-v': 'vsplit' }
2021-01-27 19:17:05 +00:00
" Vim-Go configuration:
2021-03-09 19:40:10 +00:00
let g:go_decls_mode = 'fzf'
2021-01-27 19:17:05 +00:00
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
2021-02-04 08:00:36 +00:00
let g:go_info_mode = 'gopls'
2021-03-18 08:05:37 +00:00
" ALE handles this:
let g:go_auto_type_info = 0
let g:go_echo_command_info = 1
let g:go_echo_go_info = 0
2021-01-28 08:21:55 +00:00
let g:go_highlight_functions = 1
let g:go_term_enabled = 0
let g:go_term_close_on_exit = 0
2021-01-28 19:23:15 +00:00
let g:go_gopls_analyses = {
\ 'composites': v:false,
2021-02-02 11:40:09 +00:00
\ 'unusedparams': v:true,
\ 'unusedresult': v:true,
\ 'shadow': v:true,
2021-01-28 19:23:15 +00:00
\ }
2021-01-27 19:17:05 +00:00
let g:go_fmt_options = {
2021-01-29 13:53:15 +00:00
\ 'goimports': '-local github.com/sensiblecodeio/cantabular',
2021-01-27 19:17:05 +00:00
\ }
2021-01-28 08:21:55 +00:00
2021-01-27 19:17:05 +00:00
autocmd BufNewFile,BufRead *.go nmap <silent> <leader>g6 :GoAlternate!<cr>
2021-01-27 14:32:26 +00:00
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
2021-02-23 12:42:59 +00:00
iabbrev httph http.Handler
iabbrev httphf http.HandlerFunc
2021-01-27 14:32:26 +00:00
iabbrev fttt <ESC>ccfunc TestSomething(t *testing.T) {<cr>}<esc>k9l
iabbrev ttt t *testing.T
2021-02-02 11:37:36 +00:00
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
2021-02-22 09:45:05 +00:00
iabbrev []b []byte()<esc>i
2021-03-15 15:29:40 +00:00
iabbrev logd log.Debug().Msg("
iabbrev logi log.Info().Msg("
iabbrev loge log.Error().Msg("
iabbrev logf log.Fatal().Msg("