-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
498 lines (392 loc) · 11.7 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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
set shell=bash
set history=700
filetype plugin on
filetype indent on
syntax enable
set mouse=a
set selectmode-=mouse
set autoread
set so=7
set wildmenu
set wildignore=*.o,*~,*.pyc,.git\*,.hg\*,.svn\*
set ruler
set foldcolumn=1
set number
set cmdheight=1
set scrolloff=4
" Allow hidden buffers
set hidden
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set incsearch
set ignorecase
set smartcase
set nohlsearch
set showmatch
set mat=2
set smarttab
set expandtab
set tabstop=4
set softtabstop=2
set shiftwidth=2
set autoindent
set smartindent
set listchars=tab:⇢\ ,trail:·,eol:◦
set nowrap
set foldmethod=indent
set nofoldenable
" Return to last edit position when opening files
augroup RememberLastPosition
autocmd!
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
" Remember info about open buffers on close
set viminfo^=%
augroup TrimTrailingWhitespace
autocmd!
autocmd FileType c,cpp,java,php,js,css,xml,xsl,s,go,py,haskell,h,m,ruby,coffee,yml autocmd BufWritePre * :%s/[ \t\r]\+$//e
augroup END
set nobackup
set noswapfile
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
set undodir=~/.vim/undo//
"Printing (:hardcopy) options
set printoptions=paper:letter,syntax:y,number:y,duplex:off,left:5pc
set laststatus=2
"=================
"=== FileTypes ===
"=================
augroup Markdown
autocmd!
autocmd BufRead,BufNewFile *.md setlocal filetype=markdown
autocmd FileType markdown setlocal wrap linebreak
augroup END
augroup Haskell
autocmd!
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
let g:haddock_browser="open"
augroup END
augroup Rails
autocmd!
autocmd BufRead,BufNewFile *.hamlc setlocal filetype=haml
augroup END
augroup JSON
autocmd!
autocmd BufRead,BufNewFile *.json setlocal filetype=json
autocmd FileType json set autoindent
autocmd FileType json set foldmethod=syntax
augroup END
"=============
"=== Keys! ===
"=============
" Remap <leader> from \ to <SPACE>
let mapleader = "\<SPACE>"
let g:mapleader = "\<SPACE>"
" Add <leader> based shortcuts for q/x/s/bw
nmap <leader>q :q<CR>
nmap <leader>Q :q!<CR>
nmap <leader>x :x<CR>
nmap <leader>s :w<CR>
nmap <leader>bw :w<CR>
" and add a capital W version for sudo
" (useful to avoid opening vim as sudo)
command! W w !sudo tee % > /dev/null
nmap <leader>W :W<CR>
" Autocompletion using the TAB key
" This function determines, whether we are on the start of the line text (then tab indents) or
" if we want to try autocompletion
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
" Remap the tab key to select action with InsertTabWrapper
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
" Make j/k move up/down through visual rows,
" not lines (for wrapped lines)
" ...there may be a better way to do this
noremap j gj
nnoremap <Down> gj
vnoremap <Down> gj
noremap k gk
nnoremap <Up> gk
vnoremap <Up> gk
" Split line to the left of the cursor,
" intended as the opposite of J
nnoremap K i<CR><Esc>k$
" Select previous selection
nnoremap gV `[v`]
" Toggle invis chars
nnoremap <leader>l :set list!<CR>
" Toggle recent search highlight
nnoremap <leader>/ :set hlsearch!<CR>
" Quick-open ~/.vimrc
nnoremap <leader>v :edit $MYVIMRC<CR>
" Quick-source ~/.vimrc
nnoremap <leader>V :source $MYVIMRC<CR>
" Toggle file browser left sidebar
nnoremap <leader>o :NERDTreeToggle<CR>
" Toggle Tagbar right sidebar
nnoremap <leader>tt :TagbarToggle<CR>
" Trim trailing whitespace on every line of file
nnoremap <leader>tw :%s/[ \t\r]\+$//e<CR>
" Window movement and splitting
" -----------------------------
" Alias <C-w> window movement prefix to ,w
nnoremap <leader>wh <C-w>h
nnoremap <leader>wj <C-w>j
nnoremap <leader>wk <C-w>k
nnoremap <leader>wl <C-w>l
" Split with -, / (spacemacs habit)
nnoremap <leader>w- :leftabove split<CR>
nnoremap <leader>w_ :rightbelow split<CR>
nnoremap <leader>w/ :leftabove vsplit<CR>
nnoremap <leader>w? :rightbelow vsplit<CR>
" MiniBufExpl buffer navigation
" -----------------------------
" Toggle MiniBufExpl
nmap <leader>bt :MBEToggle<CR>
nmap <leader>bb :MBEToggle<CR>
" Next/Previous buffer (listed)
nmap <leader>bl :MBEbn<CR>
nmap <leader>bh :MBEbp<CR>
" Next/Previous buffer (used)
nmap <leader>bo :MBEbb<CR>
nmap <leader>bi :MBEbf<CR>
" Create a new buffer
nmap <leader>bn :enew<CR>
" Delete buffer
nmap <leader>bq :MBEbd<CR>
nmap <leader>bd :MBEbd<CR>
"================
"=== Commands ===
"================
" Get wordcount of current file
nnoremap <leader>wc :!wc -w %<CR>
"=======================
"=== EasyMotion keys ===
"=======================
" Using `g` as a leader for a selection of
" easymotion motions, binding all in
" normal (nmap) and operator-pending (omap) modes
" gf{c} -> find a char
map gf <Plug>(easymotion-s)
" gs -> jump to any word or camelCase boundary
map gs <Plug>(easymotion-jumptoanywhere)
" gj, gk -> jump to any beginning of line
map gj <Plug>(easymotion-bd-jk)
map gk <Plug>(easymotion-bd-jk)
" gh, gl -> jump to any word boundary in line
map gl <Plug>(easymotion-lineforward)
map gh <Plug>(easymotion-linebackward)
" gw -> jump to any beginning of word
map gw <Plug>(easymotion-bd-w)
" ge -> jump to any end of word
map ge <Plug>(easymotion-bd-e)
" Use easymotion search instead of default,
" for incremental highlighting and auto-unhighlighting
map / <Plug>(easymotion-sn)
map n <Plug>(easymotion-next)
"omap n <Plug>(easymotion-next)
map N <Plug>(easymotion-prev)
"omap N <Plug>(easymotion-prev)
" Rebind '*' to search for word under cursor
map * <Plug>(easymotion-sn)<C-r><C-w><CR>
"omap * <Plug>(easymotion-sn)<C-r><C-w><CR>
" Remap the default search bindings behind 'g' leader
nnoremap g/ /
nnoremap gn n
nnoremap gN N
nnoremap g* *
highlight! link EasyMotionMoveHL Search
highlight! link EasyMotionIncSearch EasyMotionTarget2FirstDefault
"===============
"=== Airline ===
"===============
let g:airline_theme='solarized'
let g:airline_left_sep=' '
let g:airline_right_sep=' '
let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#tabline#show_buffers=0
let g:airline#extensions#tabline#left_sep=' '
let g:airline#extensions#tabline#left_alt_sep=' '
"=================
"=== GitGutter ===
"=================
highlight! link GitGutterAdd DiffAdd
highlight! link GitGutterChange DiffChange
highlight! link GitGutterDelete DiffDelete
highlight! link GitGutterChangeDelete DiffDelete
"================
"=== NERDTree ===
"================
" Show hidden files by default (togglable with I)
let NERDTreeShowHidden=1
"=================
"=== ShowMarks ===
"=================
let g:showmarks_include="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
" Prevent showmarks from keeping previous options
" if exists('loaded_showmarks')
" unlet loaded_showmarks
" endif
highlight! link ShowMarksHLl LineNr
highlight! link ShowMarksHLu LineNr
highlight! link ShowMarksHLo LineNr
highlight! link ShowMarksHLm LineNr
let g:showmarks_textlower="\t "
let g:showmarks_textupper="\t "
let g:showmarks_textother="\t "
"==================
"=== ConqueTerm ===
"==================
" currently unused...
let g:ConqueTerm_InsertOnEnter=1
let g:ConqueTerm_Color=1
let g:ConqueTerm_CWInsert=1
let g:ConqueTerm_Syntax=''
let g:ConqueTerm_TERM='xterm'
"==============
"=== Tagbar ===
"==============
let g:tagbar_autoclose=1
let g:tagbar_compact=0
let g:tagbar_indent=1
let g:tagbar_autoshowtag=1
let g:tagbar_type_coffee = {
\ 'ctagstype' : 'coffee',
\ 'kinds' : [
\ 'c:classes',
\ 'm:methods',
\ 'f:functions',
\ 'v:variables',
\ 'f:fields',
\ ]
\ }
"==============
"=== Vundle ===
"==============
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Plugins
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'airblade/vim-gitgutter'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdtree'
Plugin 'dag/vim-fish'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'kien/ctrlp.vim'
Plugin 'tommcdo/vim-exchange'
Plugin 'Shougo/vimproc.vim'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-unimpaired'
Plugin 'tpope/vim-surround'
Plugin 'mileszs/ack.vim'
" Plugin 'vim-scripts/ShowMarks'
Plugin 'majutsushi/tagbar'
Plugin 'fholgado/minibufexpl.vim'
" Colors
Plugin 'altercation/vim-colors-solarized'
" Syntaxes
Plugin 'kchmck/vim-coffee-script'
Plugin 'vim-ruby/vim-ruby'
Plugin 'elzr/vim-json'
Plugin 'raichoo/purescript-vim'
Plugin 'lervag/vimtex'
" Haskell
"Plugin 'eagletmt/ghcmod-vim'
"Plugin 'lukerandall/haskellmode-vim'
Plugin 'eagletmt/neco-ghc'
call vundle#end()
filetype plugin indent on
"==========
"=== UI ===
"==========
set background=light
set t_Co=256
colorscheme slate
"===================
"=== MiniBufExpl ===
"===================
if has('gui_running')
" These are convenient links to work with solarized (dark)
highlight! link MBENormal Comment
highlight! link MBEChanged Type
highlight! link MBEVisibleNormal Normal
highlight! link MBEVisibleChanged DiffChange
highlight! link MBEVisibleActiveNormal StatusLine
highlight! link MBEVisibleActiveChanged Search
end
"===================
"=== GUI Options ===
"===================
if has("gui_running")
set guifont=PragmataPro:h12
" https://github.com/i-tu/Hasklig/issues/32
set macligatures
" set guioptions=gtrLmec
set guioptions=gtmc
set guitablabel=%M\ %t
augroup SolarizedFixup
autocmd!
autocmd ColorScheme * call SolarizedFixup()
augroup END
function! SolarizedFixup()
if g:colors_name ==? "solarized"
highlight! link SignColumn LineNr
endif
endfunction
set background=dark
set cursorline
colorscheme solarized
endif
" ## added by OPAM user-setup for vim / base ## 8a3125e39f347f6b9a1b167d8e564281 ## you can edit, but keep this line
" let s:opam_share_dir = system("opam config var share")
" let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '')
" let s:opam_configuration = {}
" function! OpamConfOcpIndent()
" let l:file = s:opam_share_dir . "/vim/syntax/ocp-indent.vim"
" execute "source " . l:file
" endfunction
" let s:opam_configuration['ocp-indent'] = function('OpamConfOcpIndent')
" function! OpamConfOcpIndex()
" let l:file = s:opam_share_dir . "/vim/syntax/ocpindex.vim"
" execute "source " . l:file
" endfunction
" let s:opam_configuration['ocp-index'] = function('OpamConfOcpIndex')
" function! OpamConfMerlin()
" let l:dir = s:opam_share_dir . "/merlin/vim"
" execute "set rtp+=" . l:dir
" endfunction
" let s:opam_configuration['merlin'] = function('OpamConfMerlin')
" let s:opam_packages = ["ocp-indent", "ocp-index", "merlin"]
" let s:opam_check_cmdline = ["opam list --installed --short --safe --color=never"] + s:opam_packages
" let s:opam_available_tools = split(system(join(s:opam_check_cmdline, ' ')))
" for tool in s:opam_available_tools
" call s:opam_configuration[tool]()
" endfor
" " ## end of OPAM user-setup addition for vim / base ## keep this line
" " ## added by OPAM user-setup for vim / ocp-indent ## f6621413a261159e8e391a1865d30a4a ## you can edit, but keep this line
" if count(s:opam_available_tools,"ocp-indent") == 0
" source "/Users/ryanartecona/.opam/raybeam-ocaml/share/vim/syntax/ocp-indent.vim"
" endif
" " ## end of OPAM user-setup addition for vim / ocp-indent ## keep this line
" " ## added by OPAM user-setup for vim / ocp-index ## 99e2914cfb2eae6564b450e0d54f18c6 ## you can edit, but keep this line
" if count(s:opam_available_tools,"ocp-index") == 0
" source "/Users/ryanartecona/.opam/raybeam-ocaml/share/vim/syntax/ocpindex.vim"
" endif
" ## end of OPAM user-setup addition for vim / ocp-index ## keep this line