-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
146 lines (112 loc) · 3.33 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
"
" Andy Edison .vimrc
"
"
filetype plugin on
filetype indent on
"""""" Loading Plugins with Vim-Plug
call plug#begin()
Plug 'ctrlpvim/ctrlp.vim'
Plug 'fatih/vim-go'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'SirVer/ultisnips'
Plug 'fatih/molokai'
Plug 'Valloric/YouCompleteMe'
call plug#end()
"""""" APPEARANCE
" for iTerm2
"set term=xterm-256color
" color scheme
syntax on
colorscheme molokai
let g:molokai_original = 1
let g:rehash256 = 1
" font
set guifont=Courier\ New:h13
"set guifont=Source\ Code\ Pro:h13
" line numbers
set number
" match parenthesis
set showmatch
" wrapping
" mess with this more later http://vim.wikia.com/wiki/Automatic_word_wrapping
" set colorcolumn=90
" indenting settings
set nowrap
set tabstop=4
set shiftwidth=4
set expandtab
" set smartindent
set autoindent
" backspace behavior
set backspace=start,indent,eol
"Makes current line cursor is on highlighted
set cul
"""""" INTERACTION
" set new leader key
let mapleader=","
" reload vimrc without restarting vim
map <leader>s :source ~/.vimrc<CR>
" highlighting while searching
set hlsearch
" cancel search highlighting
nnoremap <silent> <Esc> :nohlsearch<Bar>:echo<CR>
"switching between tabs
noremap <C-Tab> :tabn<CR>
noremap <C-S-Tab> :tabp<CR>
"map F2 to toggle wrapping
"nnoremap <F2> :set nowrap! <CR>
"
" Toggle paste mode
" " (prefer this over 'pastetoggle' to echo current state)
nmap <leader>p :setlocal paste! paste?<cr>
" Store swap files in fixed location, not current directory
set dir=~/.vim/swap//,/var/tmp//,/tmp//,.
"
" golang and vim-go related
"
" autosaves when calling :make which vim-go does
set autowrite
" use goimports instead of gofmt
let g:go_fmt_command = "goimports"
" some go color settings
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
" make it easier to jump between errors in quickfix window
map <C-n> :cn<CR>
map <C-m> :cp<CR>
nnoremap <leader>a :cclose<CR>
" shortcuts for building and running go programs
" autocmd FileType go nmap <leader>b <Plug>(go-build)
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR>
autocmd FileType go nmap <leader>r <Plug>(go-run)
" 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#cmd#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
" easier go-coverage-toggle calling
autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle)
" go decl dir shortcut for navigating definitions between files
autocmd FileTYpe go nmap <C-g> :GoDeclsDir <CR>
" GoAlternate helper shortcuts
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')
" make it easy to call GoInfo
autocmd FileType go nmap <Leader>i <Plug>(go-info)
" because I have a terrible memory...
" `gd` calls GoDef, ctrl-t goes back
" `K` calls GoDoc
" some YCM settings
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_autoclose_preview_window_after_completion = 1