-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
522 lines (396 loc) · 12.4 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
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
" vim: set foldmethod=marker
" Plugins {{{
" ===========
call plug#begin('~/.nvim/plugged')
" Libraries
" Plug 'vim-scripts/genutils'
Plug 'xolox/vim-misc'
Plug 'svermeulen/vim-repeat'
Plug 'kana/vim-submode'
Plug 'michaeljsmith/vim-indent-object' " indent text-object
Plug 'kana/vim-operator-user'
Plug 'Shougo/unite.vim' " needed by vimfiler
" Motions
Plug 'camelcasemotion'
Plug 'wellle/targets.vim' " Add additional text-objects
Plug 'kana/vim-textobj-user' " needed by vim-textobj-xmlattr
Plug 'kana/vim-textobj-function' " function text-objects for C, java, vim (f)
Plug 'thinca/vim-textobj-function-javascript' " JS function text-object (f)
Plug 'glts/vim-textobj-comment' " A comment text-object
Plug 'whatyouhide/vim-textobj-xmlattr' " XML/HTML attribute text objects (x)
Plug 'matchit.zip' " More uses for %
Plug 'ironhouzi/vim-stim' " Better *
Plug 'easymotion/vim-easymotion'
Plug 'jeetsukumaran/vim-indentwise'
Plug 'bronson/vim-visual-star-search'
" Language-specific
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
Plug 'shime/vim-livedown', { 'for': 'markdown' }
Plug 'lervag/vimtex', { 'for': 'tex' }
Plug 'ekalinin/Dockerfile.vim', { 'for': 'Dockerfile' }
Plug 'mattn/emmet-vim', { 'for': ['html', 'htm', 'xml'] }
Plug 'digitaltoad/vim-jade', { 'for': 'jade' }
Plug 'jelera/vim-javascript-syntax'
Plug 'DeX3/vim-js-indent'
Plug 'elzr/vim-json', { 'for': 'json' }
Plug 'leafgarland/typescript-vim', { 'for': 'typescript' }
Plug 'kchmck/vim-coffee-script', { 'for': 'coffee' }
Plug 'IN3D/vim-raml', { 'for': 'raml' }
Plug 'aklt/plantuml-syntax'
" File management
Plug 'ctrlpvim/ctrlp.vim'
Plug 'danro/rename.vim'
Plug 'rking/ag.vim'
Plug 'dyng/ctrlsf.vim'
Plug 'Shougo/vimfiler.vim'
Plug 'tpope/vim-projectionist'
" editing/formatting
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'DeX3/vim-argformat'
Plug 'dhruvasagar/vim-table-mode'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'mjbrownie/swapit'
Plug 'ntpeters/vim-better-whitespace'
Plug 'tommcdo/vim-exchange'
" Visual
Plug 'DeX3/vim-smartresize'
Plug 'bling/vim-airline'
Plug 'ntpeters/vim-airline-colornum'
Plug 'Valloric/MatchTagAlways'
" Colors
Plug 'flazz/vim-colorschemes' " a lot of basic colorschemes
" Integration
Plug 'christoomey/vim-tmux-navigator'
Plug 'brauner/vimtux'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-obsession' " required for vim-prosession
Plug 'dhruvasagar/vim-prosession'
Plug 'vim-utils/vim-husk'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-eunuch' " Some unix commands as vim commands
Plug 'kopischke/vim-fetch' " open files with line numbers like file.c:22
" Misc
Plug 'benekastah/neomake'
Plug 'editorconfig/editorconfig-vim'
Plug 'Valloric/YouCompleteMe', { 'do': './install.py --tern-completer' }
Plug 'sjl/gundo.vim' " the undo-tree
Plug 'SirVer/ultisnips'
Plug 'moll/vim-bbye' " close buffers without messing up window layout
Plug 'xolox/vim-notes'
call plug#end()
" }}}
" Colors {{{
" ==========
if $COLORTERM == 'gnome-terminal'
set t_Co=256
endif
set background=light
colorscheme summerfruit256
" }}}
" Basic settings {{{
" ==================
syntax on
set number
set shiftwidth=2
set tabstop=2
set colorcolumn=80
set textwidth=0
set autoindent
set showmatch
set hlsearch
set incsearch
set ignorecase
set smartcase
set nowrap
set linebreak
set nolist
set expandtab
set smarttab
set modeline
"keep backup files in central directory (dirs have to exist)
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
" Avoid swapfiles alltogether
set noswapfile
"enable persistent undo (directory has to exist)
set undofile
set undodir=~/.vim/undo
set undolevels=1000
set undoreload=10000
" No error bells
set noeb vb t_vb=
"better tab-completion
set wildmode=longest,list,full
set wildmenu
set hidden
set scrolloff=5
set sidescrolloff=10
set sidescroll=1
set mouse=a
"Always display status bar (vim-airline)
set laststatus=2
"Always use the system register
set clipboard=unnamed,unnamedplus
" Allow backspace to delete previously entered characters
set backspace=indent,eol,start
" Fold by syntax
set foldmethod=indent
" But unfold everthing when opening a new file, so nothing is folded
set foldlevel=99
" }}}
" Mappings {{{
" ============
let mapleader = " "
let maplocalleader = "\\"
set pastetoggle=<F2>
nmap <leader>vpp :source $MYVIMRC<CR>
nmap <leader>vpi :PlugInstall<CR>
nmap <leader>vpu :PlugUpdate<CR>
nmap <leader>vpc :PlugClean<CR>
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
map N Nzz
map n nzz
" buffer related stuff
nnoremap <leader>n :enew<CR>
nnoremap <leader>j :bp<CR>
nnoremap <leader>k :bn<CR>
nnoremap <leader>q :Bdelete<CR> " use command from moll/vim-bbye
nnoremap <leader><S-q> :bufdo bd<CR>
nnoremap tn :tabnew<CR>
nnoremap tj :tabp<CR>
nnoremap tk :tabn<CR>
" Movement in wrapped lines
nnoremap j gj
nnoremap k gk
nnoremap 0 g0
nnoremap $ g$
" save with leader s
nmap <leader>s :w<CR>
" save with C-s (when forwarding is enabled in terminal, or in gui)
nmap <C-s> :w<CR>
" enable camelcasemotion
nmap w ,w
nmap b ,b
nmap e ,e
" Redirect all delete-operations to black-hole
" Use 'm' ("move") for all cut-operations
nnoremap d "_d
nnoremap m d
nnoremap mm dd
vnoremap d "_d
vnoremap m d
nnoremap c "_c
nnoremap x "_x
nnoremap <leader>x x
" Open the file name currently under the cursor even if it does not exist (for
" creating a new file). Must use "%:h" to properly get the file path relative
" to the current file
nmap <leader>gf :exe 'e ' . expand("%:h") . '/' . expand("<cfile>")<CR>
" remap p in visual mode to first delete to blackhole to prevent tainting yank
" register
xnoremap p "_dP
" Use gm for marks instead of normal m
nnoremap gm m
" Clear highlighting on escape in normal mode
nnoremap <esc> :noh<return><esc>
" needed so that vim still understands escape sequences
nnoremap <esc>^[ <esc>^[
" window-stuff with leader w
nmap <leader>ws :split<CR>
nmap <leader>w<S-s> :vsplit<CR>
nmap <leader>wq <C-w>q
" Toggle NERDTree with leader w t
nmap <leader>wt :NERDTreeToggle<CR>
nmap g/ <Plug>CtrlSFPrompt
nmap <Leader>fu :call UnWrap()<CR>
"press gp to reselect pasted text
nnoremap <expr> gp '`[' . strpart(getregtype(), 0, 1) . '`]'
nmap <S-u> :GundoToggle<CR>
nmap <Leader><Leader> :call ExecuteKeys( 'Up Enter' )<CR>
" I keep pressing this accidentally way to often...
nmap q: <Nop>
nmap <Leader>fc :ArgFormatConcise<CR>
nmap <Leader>fm :ArgFormatMultiline<CR>
nmap <Leader>fp :ArgFormatOnPar<CR>
" duplicate the above block with <leader>db
nnoremap <Leader>db mp?)\\|]\\|}<CR><S-v>%y`pp:nohl<CR>
imap <C-l> <Del>
" Easier to type umlauts, make sure to set M-u and M-s accordingly in
" .vimrc.local
" e.g. set <M-u>=u
" generate the u by pressing <C-v> and then <M-u>!
imap <M-u> <C-k>:
imap <M-s> <C-k>ss
" Use C-p to duplicate a block of code in visual mode
vmap <Leader>db y`>p
" Leader-p instead of =p for indented paste
nmap <Leader>p =p
nnoremap <Tab> %
" navigate jumplist
nnoremap [j <C-o>
nnoremap ]j <C-i>
" navigate changelist
nnoremap [c g;
nnoremap ]c g,
" Switch to alternate file via projectionist
nnoremap <Leader>a :A<CR>
call submode#enter_with('vresize', 'n', '', '<leader>wj', ':SmartResizeJ<CR>')
call submode#enter_with('vresize', 'n', '', '<leader>wk', ':SmartResizeK<CR>')
call submode#leave_with('vresize', 'n', '', '<Esc>')
call submode#map('vresize', 'n', '', 'j', ':SmartResizeJ<CR>' )
call submode#map('vresize', 'n', '', 'k', ':SmartResizeK<CR>')
call submode#enter_with('resize', 'n', '', '<leader>wh', ':SmartResizeH<CR>')
call submode#enter_with('resize', 'n', '', '<leader>wl', ':SmartResizeL<CR>')
call submode#leave_with('resize', 'n', '', '<Esc>')
call submode#map('resize', 'n', '', 'h', ':SmartResizeH<CR>' )
call submode#map('resize', 'n', '', 'l', ':SmartResizeL<CR>')
" }}}
" Plugin-specific {{{
"Enable emmet only for html-ish files
let g:user_emmet_install_global = 0
autocmd FileType html,css,xml EmmetInstall
let g:ycm_autoclose_preview_window_after_completion = 1
" make YCM compatible with UltiSnips
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<Tab>"
let g:UltiSnipsJumpForwardTrigger = "<C-f>"
let g:UltiSnipsJumpBackwardTrigger = "<C-b>"
"check for correct indentation only
let g:airline#extensions#whitespace#checks = [ 'indent' ]
" allow spaces after tabs
let g:airline#extensions#whitespace#mixed_indent_algo = 1
"display buffers
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
"use powerline fonts
let g:airline_powerline_fonts = 1
let g:neomake_javascript_enabled_makers = ['jshint', 'jscs']
let g:neomake_haskell_enabled_makers = ['hlint']
"disable folding for vim-markdown (to prevent everything being folded on open)
let g:vim_markdown_folding_disabled=1
"don't conceal quotes in json files
let g:vim_json_syntax_conceal=0
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
let g:vimtex_fold_enabled = 0
let g:tex_flavor = 'latex'
let g:vimtex_indent_enabled = 0
let g:ctrlsf_position = 'bottom'
let g:ctrlsf_indent = 2
let g:ctrlsf_default_root = 'cwd'
let g:ctrlsf_mapping = {
\ "next": "n",
\ "prev": "N",
\ }
let g:jsdoc_allow_input_prompt = 1
let g:jsdoc_input_description = 0
let g:jsdoc_input_return_description = 0
let g:argformat_spaces_around_arglist = 1
let g:EasyMotion_do_mapping = 0
nmap <leader>fj <Plug>(easymotion-bd-jk)
nmap <leader>fk <Plug>(easymotion-bd-jk)
nmap <leader>fw <Plug>(easymotion-bd-w)
nmap <leader>ff <Plug>(easymotion-bd-f)
" Delete a block
nmap dab $d%dd
let g:AutoPairsShortcutBackInsert = '<M-b>'
let g:vimfiler_as_default_explorer = 1
" }}}
" autocmd {{{
autocmd BufWrite * :Neomake
autocmd BufNewFile,BufRead *.ejs set filetype=html
autocmd BufNewFile,BufRead *.jade set filetype=jade
autocmd FileType less set filetype=less
autocmd FileType markdown,tex,gitcommit setlocal spell
autocmd FileType notes setlocal textwidth=120 colorcolumn=0
" Automatically set nopaste when exiting insert mode
autocmd InsertLeave * set nopaste
" Automatically resize splits when window is resized
autocmd VimResized * exe "normal! \<c-w>="
autocmd FileType javascript autocmd BufWritePre <buffer> StripWhitespace
" Set ctrlp method depending on whether ag is available or not
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
else
let g:ctrlp_custom_ignore = '\v[\/](.git|
\.hg|
\.svn|
\node_modules|
\bower_components|
\.session.vim)$'
endif
" }}}
" misc {{{
" ========
" Unwraps a block of code
function! UnWrap()
let cursor = getpos( "." )
:normal $<%
:normal $%dd
call setpos( ".", cursor )
:normal dd
endfunction
command! -nargs=+ Silent execute 'silent <args>' | redraw!
function! g:PulseCursorLine()
setlocal cursorline
redraw
sleep 75m
setlocal nocursorline
redraw
sleep 75m
setlocal cursorline
redraw
sleep 75m
setlocal nocursorline
redraw
endfunction
autocmd FocusGained * call g:PulseCursorLine()
nmap gg gg:call g:PulseCursorLine()<CR>
" }}}
" GUI-specific {{{
" ================
if has("gui_running")
" Remove Toolbar
set guioptions-=T
endif
" }}}
" tmux-specific {{{
" =================
" set up vimtux' variables so that target always points to first pane of first
" window of open session
if $TMUX != ''
let g:vimtux = {}
let session = system( "tmux display-message -p '#S'" )
let g:vimtux['session'] = strpart( session, 0, len(session) - 1 )
let g:vimtux['window'] = '0'
let g:vimtux['pane'] = '0'
endif
" }}}
" source {{{
" Use vim's abbreviations file directly
if filereadable( $HOME.'/.vimrc.abbreviations' )
source ~/.vimrc.abbreviations
endif
if filereadable( '.vimrc.abbreviations' )
source .vimrc.abbreviations
endif
" If ~/.nvimrc.local exists, source it to support host-local configs
if filereadable( $HOME.'/.nvimrc.local' )
source ~/.nvimrc.local
endif
" If .nvimrc.local exists in current directory, to support project-local configs
if filereadable( ".nvimrc.local" )
source .nvimrc.local
endif
if isdirectory( '.vim/snippets' )
let g:UltiSnipsSnippetDirectories = ['UltiSnips', getcwd() . '/.vim/snippets']
endif
" }}}