Skip to content

Instantly share code, notes, and snippets.

@alexniver
Created February 14, 2019 14:47
Show Gist options
  • Save alexniver/505b6240c2b03115f2daf2fba959807e to your computer and use it in GitHub Desktop.
Save alexniver/505b6240c2b03115f2daf2fba959807e to your computer and use it in GitHub Desktop.
  1. 首先根据官方文档安装spf13.vim
  2. 执行下面的语句
echo "let g:spf13_bundle_groups=['general', 'youcompleteme', 'programming', 'go', 'javascript', 'html', 'misc', 'writing' ]" >> ~/.vimrc.before.local 
vim +BundleInstall! +qall
  1. 将下面的配置加入到 .vimrc.local
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'

" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"

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')

" 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>r  <Plug>(go-run)
autocmd FileType go nmap <leader>t  <Plug>(go-test)
autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle)

let g:go_fmt_command = "goimports"
let g:go_fmt_fail_silently = 1
let g:go_addtags_transform = "camelcase"
let g:go_list_type = "quickfix"
let g:go_test_timeout = '10s'
let g:go_highlight_types = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_generate_tags = 1
let g:go_metalinter_autosave = 1
let g:go_metalinter_deadline = "5s"
let g:go_auto_sameids = 1

autocmd FileType go nmap <Leader>i <Plug>(go-info)
let g:go_auto_type_info = 1

" nerdtree
map <F2> :NERDTreeToggle<CR>
let NERDTreeQuitOnOpen=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment