-
-
Save qloog/d56240d9319c6342f18113cba511f7e6 to your computer and use it in GitHub Desktop.
Nvim Go configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"-- vim-go specific configuration | |
" 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 | |
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR> | |
autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle) | |
autocmd FileType go nmap <leader>t <Plug>(go-test) | |
autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit') | |
autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit') | |
autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split') | |
autocmd Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe') | |
autocmd FileType go setlocal foldmethod=expr foldexpr=getline(v:lnum)=~'^\s*'.&commentstring[0] | |
let g:go_list_type = "quickfix" " error lists are of type quickfix | |
let g:go_fmt_command = "goimports" " automatically format and rewrite imports | |
let g:go_auto_sameids = 1 " highlight matching identifiers | |
"-- vim-go specific configuration (END) | |
"-- coc.nvim specific configuration | |
set hidden | |
set cmdheight=2 | |
set updatetime=300 | |
set shortmess+=c | |
if has("patch-8.1.1564") | |
set signcolumn=number | |
else | |
set signcolumn=yes | |
endif | |
nmap <silent> gr <Plug>(coc-references) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> rn <Plug>(coc-rename) | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
"-- coc.nvim specific configuration (END) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment