-
Notifications
You must be signed in to change notification settings - Fork 43
/
vimrc
390 lines (298 loc) · 11.2 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
" General "{{{
set nocompatible " be iMproved
scriptencoding utf-8 " utf-8 all the way
set encoding=utf-8
set history=256 " Number of things to remember in history.
set timeoutlen=250 " Time to wait after ESC (default causes an annoying delay)
set clipboard+=unnamed " Yanks go on clipboard instead.
set pastetoggle=<F10> " toggle between paste and normal: for 'safer' pasting from keyboard
set shiftround " round indent to multiple of 'shiftwidth'
set tags=.git/tags;$HOME " consider the repo tags first, then
" walk directory tree upto $HOME looking for tags
" note `;` sets the stop folder. :h file-search
set modeline
set modelines=5 " default numbers of lines to read for modeline instructions
set autowrite " Writes on make/shell commands
set autoread
set nobackup
set nowritebackup
set directory=/tmp// " prepend(^=) $HOME/.tmp/ to default path; use full path as backup filename(//)
set noswapfile "
set hidden " The current buffer can be put to the background without writing to disk
set hlsearch " highlight search
set ignorecase " be case insensitive when searching
set smartcase " be case sensitive when input has a capital letter
set incsearch " show matches while typing
let g:is_posix = 1 " vim's default is archaic bourne shell, bring it up to the 90s
let mapleader = ','
let maplocalleader = ' ' " Tab as a local leader
let g:netrw_banner = 0 " do not show Netrw help banner
" "}}}
" Formatting "{{{
set fo+=o " Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode.
set fo-=r " Do not automatically insert a comment leader after an enter
set fo-=t " Do no auto-wrap text using textwidth (does not apply to comments)
set nowrap
set textwidth=0 " Don't wrap lines by default
set tabstop=2 " tab size eql 2 spaces
set softtabstop=2
set shiftwidth=2 " default shift width for indents
set expandtab " replace tabs with ${tabstop} spaces
set smarttab "
set backspace=indent
set backspace+=eol
set backspace+=start
set autoindent
set cindent
set indentkeys-=0# " do not break indent on #
set cinkeys-=0#
set cinoptions=:s,ps,ts,cs
set cinwords=if,else,while,do
set cinwords+=for,switch,case
" "}}}
" Visual "{{{
syntax on " enable syntax
" set synmaxcol=250 " limit syntax highlighting to 128 columns
set mouse=a "enable mouse in GUI mode
set mousehide " Hide mouse after chars typed
set nonumber " line numbers Off
set showmatch " Show matching brackets.
set matchtime=2 " Bracket blinking.
set wildmode=longest,list " At command line, complete longest common string, then list alternatives.
set completeopt-=preview " disable auto opening preview window
set novisualbell " No blinking
set noerrorbells " No noise.
set vb t_vb= " disable any beeps or flashes on error
set laststatus=2 " always show status line.
set shortmess=atI " shortens messages
set showcmd " display an incomplete command in statusline
set statusline=%<%f\ " custom statusline
set stl+=[%{&ff}] " show fileformat
set stl+=%y%m%r%=
set stl+=%-14.(%l,%c%V%)\ %P
set foldenable " Turn on folding
set foldmethod=marker " Fold on the marker
set foldlevel=100 " Don't autofold anything (but I can still fold manually)
set foldopen=block,hor,tag " what movements open folds
set foldopen+=percent,mark
set foldopen+=quickfix
set virtualedit=block
set splitbelow
set splitright
set list " display unprintable characters f12 - switches
set listchars=tab:\ ·,eol:¬
set listchars+=trail:·
set listchars+=extends:»,precedes:«
map <silent> <F12> :set invlist<CR>
if has('gui_running')
set guioptions=cMg " console dialogs, do not show menu and toolbar
" Fonts
" :set guifont=* " to launch a GUI dialog
if has('mac')
if has('macligatures')
set antialias macligatures guifont=Fira\ Code\ Light:h13 " -> <=
else
set noantialias guifont=Andale\ Mono:h14
end
set fuoptions=maxvert,maxhorz ",background:#00AAaaaa
else
set guifont=Terminus:h16
end
endif
" "}}}
" Key mappings " {{{
" Duplication
nnoremap <leader>c mz"dyy"dp`z
vnoremap <leader>c "dymz"dP`z
nnoremap <leader>rs :source ~/.vimrc<CR>
nnoremap <leader>rt :tabnew ~/.vim/vimrc<CR>
nnoremap <leader>re :e ~/.vim/vimrc<CR>
nnoremap <leader>rd :e ~/.vim/ <CR>
nnoremap <leader>rc :silent ! cd ~/.vim/ && git commit ~/.vim/vimrc -v <CR>
" Tabs
nnoremap <M-h> :tabprev<CR>
nnoremap <M-l> :tabnext<CR>
" Buffers
nnoremap <localleader>- :bd<CR>
nnoremap <localleader>-- :bd!<CR>
" Split line(opposite to S-J joining line)
nnoremap <C-J> gEa<CR><ESC>ew
" map <silent> <C-W>v :vnew<CR>
" map <silent> <C-W>s :snew<CR>
" copy filename
map <silent> <leader>. :let @+=expand('%:p').':'.line('.')<CR>
map <silent> <leader>/ :let @+=expand('%:p:h')<CR>
" copy path
map <S-CR> A<CR><ESC>
map <leader>E :Explore<CR>
map <leader>EE :Vexplore!<CR><C-W>=
" toggle search highlighting
nnoremap <silent> <space> :let &hls=1-&hls<cr>
" Make Control-direction switch between windows (like C-W h, etc)
nmap <silent> <C-k> <C-W><C-k>
nmap <silent> <C-j> <C-W><C-j>
nmap <silent> <C-h> <C-W><C-h>
nmap <silent> <C-l> <C-W><C-l>
" vertical paragraph-movement
nmap <C-K> {
nmap <C-J> }
" vertical split with fuzzy-searcher
nnoremap <leader>v :exec ':vnew \| CtrlP'<CR>
" and without
nnoremap <leader>V :vnew<CR>
" when pasting copy pasted text back to
" buffer instead replacing with owerride
xnoremap p pgvy
if has('mac')
if has('gui_running')
set macmeta
end
" map(range(1,9), 'exec "imap <D-".v:val."> <C-o>".v:val."gt"')
" map(range(1,9), 'exec " map <D-".v:val."> ".v:val."gt"')
" Copy whole line
nnoremap <silent> <D-c> yy
" close/delete buffer when closing window
map <silent> <D-w> :bdelete<CR>
endif
" Control+S and Control+Q are flow-control characters: disable them in your terminal settings.
" $ stty -ixon -ixoff
noremap <C-S> :update<CR>
vnoremap <C-S> <C-C>:update<CR>
inoremap <C-S> <C-O>:update<CR>
"
" generate HTML version current buffer using current color scheme
map <leader>2h :runtime! syntax/2html.vim<CR>
" " }}}
" AutoCommands " {{{
au BufRead,BufNewFile {*.go} setl ft=go tabstop=2 softtabstop=2 noexpandtab smarttab
au BufRead,BufNewFile {*.coffee} setl ft=coffee tabstop=2 softtabstop=2 expandtab smarttab
au BufRead,BufNewFile {Gemfile,Rakefile,*.rake,config.ru,*.rabl} setl ft=ruby tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab
au BufRead,BufNewFile {*.local} setl ft=sh
au BufRead,BufNewFile {*.md,*.mkd,*.markdown} setl ft=markdown
au BufRead,BufNewFile {*.scala} setl ft=scala
au! BufReadPost {COMMIT_EDITMSG,*/COMMIT_EDITMSG} exec 'setl ft=gitcommit noml list spell' | norm 1G
au! BufWritePost {*.snippet,*.snippets} call ReloadAllSnippets()
" open help in vertical split
" au BufWinEnter {*.txt} if 'help' == &ft | wincmd H | nmap q :q<CR> | endif
" " }}}
" Scripts and Plugins " {{{
filetype off
runtime macros/matchit.vim
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Plugin 'gmarik/vundle' " let Vundle manage Vundle
" Colorscheme
Plugin 'gmarik/ingretu'
if has("gui_running")
colorscheme ingretu
endif
" Programming
" Python
Plugin 'davidhalter/jedi-vim'
Plugin 'klen/python-mode'
let g:pymode_lint = 0
" Golang
Plugin 'fatih/vim-go'
" unlike gofmt also adds/removes imports
let g:go_fmt_command = 'gofmt'
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_build_constraints = 1
nnoremap <leader>gt :GoTest<CR>
nnoremap <leader>gv :GoVet<CR>
nnoremap <leader>gl :GoLint<CR>
" goes to the definition under cursor in a new split
" TODO: doesn't work
nnoremap <C-W>gd <C-W>^zz
" Scala
Plugin 'derekwyatt/vim-scala'
" Ruby/Rails
Plugin 'tpope/vim-rails'
" Js
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
" Snippets
Plugin 'gmarik/snipmate.vim'
Plugin 'gmarik/snipmate.snippets'
nnoremap <leader>so :Explore ~/.vim/bundle/snipmate.snippets/snippets/<CR>
" Syntax highlight
Plugin 'gmarik/vim-markdown'
Plugin 'timcharper/textile.vim'
" Git integration
Plugin 'tpope/vim-git'
Plugin 'tpope/vim-fugitive'
Plugin 'junegunn/gv.vim'
nnoremap <leader>W :Gwrite<CR>
nnoremap <leader>C :Gcommit -v<CR>
nnoremap <leader>S :Gstatus \| 7<CR>
inoremap <leader>W <Esc><leader>W
inoremap <leader>C <Esc><leader>C
inoremap <leader>S <Esc><leader>S
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-unimpaired'
" bubble current line
nmap <M-j> ]e
nmap <M-k> [e
" bubble visual selection lines
vmap <M-j> ]egv
vmap <M-k> [egv
" Utility
Plugin 'AndrewRadev/splitjoin.vim'
nmap sj :SplitjoinJoin<cr>
nmap sk :SplitjoinSplit<cr>
Plugin 'gmarik/github-search.vim'
Plugin 'gmarik/ide-popup.vim'
Plugin 'gmarik/sudo-gui.vim'
Plugin 'sjl/gundo.vim'
Plugin 'mkitt/browser-refresh.vim'
com! ONRRB :au! BufWritePost <buffer> :RRB
com! NORRB :au! BufWritePost <buffer>
" Plugin 'SuperTab'
Plugin 'bogado/file-line'
Plugin 'junegunn/vim-easy-align'
Plugin 'vim-scripts/lastpos.vim'
Plugin 'Lokaltog/vim-easymotion'
let g:EasyMotion_leader_key='<LocalLeader>'
Plugin 'ZoomWin'
noremap <leader>o :ZoomWin<CR>
vnoremap <leader>o <C-C>:ZoomWin<CR>
inoremap <leader>o <C-O>:ZoomWin<CR>
Plugin 'tomtom/tlib_vim'
Plugin 'tomtom/tcomment_vim'
nnoremap // :TComment<CR>
vnoremap // :TComment<CR>
Plugin 'gmarik/hlmatch.vim'
nnoremap # :<C-u>HlmCword<CR>
nnoremap <leader># :<C-u>HlmGrepCword<CR>
vnoremap # :<C-u>HlmVSel<CR>
vnoremap <leader># :<C-u>HlmGrepVSel<CR>
nnoremap ## :<C-u>HlmPartCword<CR>
nnoremap <leader>## :<C-u>HlmPartGrepCword<CR>
vnoremap ## :<C-u>HlmPartVSel<CR>
vnoremap <leader>## :<C-u>HlmPartGrepVSel<CR>
Plugin 'ctrlpvim/ctrlp.vim'
let g:ctrlp_map = '<leader>t'
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10'
let g:ctrlp_extensions = ['tag', 'buffertag', 'dir', 'rtscript',
\ 'undo', 'line', 'changes', 'mixed', 'bookmarkdir']
nnoremap <leader>0 :CtrlPClearAllCaches<CR>
nnoremap <leader>` :CtrlPUndo<CR>
nnoremap <leader>1 :CtrlPTag expand("<cword>")<CR>
nnoremap <leader>11 :CtrlPTag<CR>
nnoremap <leader>2 :CtrlP expand("%:h:p")<CR>
nnoremap <leader>22 :CtrlP<CR>
nnoremap <leader>3 :CtrlPBuffer<CR>
nnoremap <leader>4 :CtrlPDir expand("%:h:p")<CR>
nnoremap <leader>44 :CtrlPDir<CR>
nnoremap <leader>6 :CtrlPMRU<CR>
nnoremap <leader>7 :CtrlPLine<CR>
nnoremap <leader>8 :CtrlPChange<CR>
nnoremap <leader>9 :CtrlPChange<CR>
nnoremap <leader>h :CtrlPRTS<CR>
Plugin 'rstacruz/sparkup.git', {'rtp': 'vim/'}
let g:sparkupExecuteMapping = '<c-e>'
let g:sparkupNextMapping = '<c-ee>'
filetype plugin indent on " Automatically detect file types.
" " }}}