Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- call plug#begin()
- Plug 'nsf/gocode', { 'rtp': 'vim', 'do': '~/.vim/plugged/gocode/vim/symlink.sh' }
- Plug 'fatih/vim-go'
- Plug 'fatih/molokai'
- Plug 'SirVer/ultisnips'
- Plug 'ctrlpvim/ctrlp.vim'
- call plug#end()
- set nocompatible " Enables us Vim specific features
- filetype off " Reset filetype detection first ...
- filetype plugin indent on " ... and enable filetype detection
- set ttyfast " Indicate fast terminal conn for faster redraw
- set ttymouse=xterm2 " Indicate terminal type for mouse codes
- set ttyscroll=3 " Speedup scrolling
- set laststatus=2 " Show status line always
- set encoding=utf-8 " Set default encoding to UTF-8
- set autoread " Automatically read changed files
- set autoindent " Enabile Autoindent
- set backspace=indent,eol,start " Makes backspace key more powerful.
- set incsearch " Shows the match while typing
- set hlsearch " Highlight found searches
- set noerrorbells " No beeps
- set number " Show line numbers
- set showcmd " Show me what I'm typing
- set noswapfile " Don't use swapfile
- set nobackup " Don't create annoying backup files
- set splitright " Vertical windows should be split to right
- set splitbelow " Horizontal windows should split to bottom
- set autowrite " Automatically save before :next, :make etc.
- set hidden " Buffer should still exist if window is closed
- set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats
- set noshowmatch " Do not show matching brackets by flickering
- set noshowmode " We show the mode with airline or lightline
- set ignorecase " Search case insensitive...
- set smartcase " ... but not it begins with upper case
- set completeopt=menu,menuone " Show popup menu, even if there is one entry
- set pumheight=10 " Completion window max size
- set nocursorcolumn " Do not highlight column (speeds up highlighting)
- set nocursorline " Do not highlight cursor (speeds up highlighting)
- set lazyredraw " Wait to redraw
- " colorscheme
- syntax enable
- set t_Co=256
- let g:rehash256 = 1
- let g:molokai_original = 1
- colorscheme molokai
- " mapping
- map <C-n> :cnext<CR>
- map <C-m> :cprevious<CR>
- nnoremap <leader>a :cclose<CR>
- nmap <C-g> :GoDeclsDir<cr>
- imap <C-g> <esc>:<C-u>GoDeclsDir<cr>
- " vim-go settings
- let g:go_fmt_command = "goimports"
- let g:go_autodetect_gopath = 1
- let g:go_list_type = "quickfix"
- let g:go_highlight_types = 1
- let g:go_highlight_fields = 1
- let g:go_highlight_functions = 1
- let g:go_highlight_function_calls = 1
- let g:go_highlight_extra_types = 1
- let g:go_highlight_generate_tags = 1
- augroup go
- autocmd!
- " Show by default 4 spaces for a tab
- autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
- " :GoBuild and :GoTestCompile
- autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR>
- " :GoTest
- autocmd FileType go nmap <leader>t <Plug>(go-test)
- " :GoRun
- autocmd FileType go nmap <leader>r <Plug>(go-run)
- " :GoDoc
- autocmd FileType go nmap <Leader>d <Plug>(go-doc)
- " :GoCoverageToggle
- autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle)
- " :GoInfo
- autocmd FileType go nmap <Leader>i <Plug>(go-info)
- " :GoMetaLinter
- autocmd FileType go nmap <Leader>l <Plug>(go-metalinter)
- " :GoDef but opens in a vertical split
- autocmd FileType go nmap <Leader>v <Plug>(go-def-vertical)
- " :GoDef but opens in a horizontal split
- autocmd FileType go nmap <Leader>s <Plug>(go-def-split)
- augroup END
- " build_go_files is a custom function that builds or compiles the test file.
- " It calls :GoBuild if its a Go file, or :GoTestCompile if it's a test 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement