Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. call plug#begin()
  2. Plug 'nsf/gocode', { 'rtp': 'vim', 'do': '~/.vim/plugged/gocode/vim/symlink.sh' }
  3. Plug 'fatih/vim-go'
  4. Plug 'fatih/molokai'
  5. Plug 'SirVer/ultisnips'
  6. Plug 'ctrlpvim/ctrlp.vim'
  7. call plug#end()
  8.  
  9. set nocompatible " Enables us Vim specific features
  10. filetype off " Reset filetype detection first ...
  11. filetype plugin indent on " ... and enable filetype detection
  12. set ttyfast " Indicate fast terminal conn for faster redraw
  13. set ttymouse=xterm2 " Indicate terminal type for mouse codes
  14. set ttyscroll=3 " Speedup scrolling
  15. set laststatus=2 " Show status line always
  16. set encoding=utf-8 " Set default encoding to UTF-8
  17. set autoread " Automatically read changed files
  18. set autoindent " Enabile Autoindent
  19. set backspace=indent,eol,start " Makes backspace key more powerful.
  20. set incsearch " Shows the match while typing
  21. set hlsearch " Highlight found searches
  22. set noerrorbells " No beeps
  23. set number " Show line numbers
  24. set showcmd " Show me what I'm typing
  25. set noswapfile " Don't use swapfile
  26. set nobackup " Don't create annoying backup files
  27. set splitright " Vertical windows should be split to right
  28. set splitbelow " Horizontal windows should split to bottom
  29. set autowrite " Automatically save before :next, :make etc.
  30. set hidden " Buffer should still exist if window is closed
  31. set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats
  32. set noshowmatch " Do not show matching brackets by flickering
  33. set noshowmode " We show the mode with airline or lightline
  34. set ignorecase " Search case insensitive...
  35. set smartcase " ... but not it begins with upper case
  36. set completeopt=menu,menuone " Show popup menu, even if there is one entry
  37. set pumheight=10 " Completion window max size
  38. set nocursorcolumn " Do not highlight column (speeds up highlighting)
  39. set nocursorline " Do not highlight cursor (speeds up highlighting)
  40. set lazyredraw " Wait to redraw
  41.  
  42. " colorscheme
  43. syntax enable
  44. set t_Co=256
  45. let g:rehash256 = 1
  46. let g:molokai_original = 1
  47. colorscheme molokai
  48.  
  49. " mapping
  50. map <C-n> :cnext<CR>
  51. map <C-m> :cprevious<CR>
  52. nnoremap <leader>a :cclose<CR>
  53. nmap <C-g> :GoDeclsDir<cr>
  54. imap <C-g> <esc>:<C-u>GoDeclsDir<cr>
  55.  
  56. " vim-go settings
  57. let g:go_fmt_command = "goimports"
  58. let g:go_autodetect_gopath = 1
  59. let g:go_list_type = "quickfix"
  60.  
  61. let g:go_highlight_types = 1
  62. let g:go_highlight_fields = 1
  63. let g:go_highlight_functions = 1
  64. let g:go_highlight_function_calls = 1
  65. let g:go_highlight_extra_types = 1
  66. let g:go_highlight_generate_tags = 1
  67.  
  68. augroup go
  69. autocmd!
  70.  
  71. " Show by default 4 spaces for a tab
  72. autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
  73.  
  74. " :GoBuild and :GoTestCompile
  75. autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR>
  76.  
  77. " :GoTest
  78. autocmd FileType go nmap <leader>t <Plug>(go-test)
  79.  
  80. " :GoRun
  81. autocmd FileType go nmap <leader>r <Plug>(go-run)
  82.  
  83. " :GoDoc
  84. autocmd FileType go nmap <Leader>d <Plug>(go-doc)
  85.  
  86. " :GoCoverageToggle
  87. autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle)
  88.  
  89. " :GoInfo
  90. autocmd FileType go nmap <Leader>i <Plug>(go-info)
  91.  
  92. " :GoMetaLinter
  93. autocmd FileType go nmap <Leader>l <Plug>(go-metalinter)
  94.  
  95. " :GoDef but opens in a vertical split
  96. autocmd FileType go nmap <Leader>v <Plug>(go-def-vertical)
  97. " :GoDef but opens in a horizontal split
  98. autocmd FileType go nmap <Leader>s <Plug>(go-def-split)
  99.  
  100. augroup END
  101.  
  102. " build_go_files is a custom function that builds or compiles the test file.
  103. " It calls :GoBuild if its a Go file, or :GoTestCompile if it's a test file
  104. function! s:build_go_files()
  105. let l:file = expand('%')
  106. if l:file =~# '^\f\+_test\.go$'
  107. call go#test#Test(0, 1)
  108. elseif l:file =~# '^\f\+\.go$'
  109. call go#cmd#Build(0)
  110. endif
  111. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement