-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
612 lines (490 loc) · 16.5 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
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pathogen
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"filetype off
"call pathogen#runtime_append_all_bundles()
"call pathogen#helptags()
execute pathogen#infect()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Autocommands
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("autocmd")
filetype plugin on
filetype plugin indent on
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Modeline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set modeline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Indentation settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
setlocal tabstop=4
setlocal shiftwidth=4
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Clipboard Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Disables selection to x11 clipboard
set clipboard-=autoselect
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" UI Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set guioptions-=m
set guioptions-=r
set guioptions-=l
set guioptions-=b
set guioptions-=T
set guioptions-=R
set guioptions-=L
" Syntax coloring
syntax on
" Disables bell
set visualbell
if has("gui_running")
colorschem wombat
augroup BgHighlight
autocmd!
autocmd WinEnter * set cursorline
autocmd WinLeave * set nocursorline
augroup END
else
if has("termguicolors")
set t_Co=256
colorschem wombat256
set cursorline
"set lazyredraw
endif
endif
" Displays ruler
set ruler
" Highlight end of line whitespace.
highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/
" Colorise les nbsp
highlight NbSp ctermbg=red guibg=red
match NbSp /\%xa0/
" Displayes 80 columns margin
if exists('+colorcolumn')
set colorcolumn=80
else
" Highlight rows longer than 79 columns
highlight rightMargin ctermbg=darkblue guibg=darkblue
match rightMargin /\%>79v.\+/
endif
" Fonts settings
if has("win32")
" fonts
set guifont=Courier_New:h10
else
"set guifont=Monospace\ 10
set guifont=Deja\ Vu\ Sans\ Mono\ 9
endif
"set wildmenu
set wildchar=<Tab> wildmenu wildmode=longest,full
set nu
" Always show some lines above or below the cursor.
set scrolloff=5
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Backup settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set backup
if has("win32")
" Store all backup and temporary files in one place
set backupdir=~/vimfiles/backup,~/,.
set directory=~/vimfiles/tmp,~/,.
else
" Store all backup and temporary files in one place
set backupdir=~/.vim/backup,~/,.
set directory=~/.vim/tmp,~/,.
endif
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.viminfo
"" Restores last cursor position
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Netrw settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Netrw setting
let g:netrw_silent = 1
if has("win32")
let g:netrw_cygwin = 0
" Putty has to be in PATH environment variable
let g:netrw_scp_cmd = "pscp.exe"
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Search settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Search while typing
set incsearch
" Show matching parens
set showmatch
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Mail filetytpe detection
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufNewFile,BufRead neomutt-* setf mail
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Removes trailing white spaces on save
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"auto remove whitespace at the end of line before :w,
"it also save email signiture spliter "-- "
"function! s:RemoveWhiteSpace()
" let save_cursor = getpos(".")
" %s/\s\+$//e
" if &filetype == 'mail'
" %s/^--$/-- /e
" endif
" call setpos(".", save_cursor)
"endfunction
function! s:RemoveWhiteSpace()
if &filetype == 'mail'
return
endif
let cursor_pos = getpos(".")
%s/\s\+$//e
call setpos(".", cursor_pos)
endfunction
autocmd BufWritePre * :call <SID>RemoveWhiteSpace()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: Pymode
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:pymode_syntax_print_as_function = 1
let g:pymode_doc = 0
let g:pymode_folding = 0
let g:pymode_rope_guess_project = 0
let g:pymode_rope_lookup_project = 0
let g:pymode_lint_cwindow = 0
let g:pymode_doc = 0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: Supertab
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Supertab
let g:SuperTabDefaultCompletionType = "context"
let g:SuperTabContextDefaultCompletionType="<C-X><C-O>"
if has("gui_running")
let g:SuperTabMappingForward = '<c-space>'
let g:SuperTabMappingBackward = '<s-c-space>'
else
let g:SuperTabMappingForward = '<nul>'
let g:SuperTabMappingBackward = '<s-nul>'
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: TaskList
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:tlWindowPosition = 1
"let g:tlTokenList = ['TODO', 'FIXME', 'XXX', 'BUG']
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: TagList
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Taglist variables
" Display function name in status bar:
"let g:ctags_statusline=1
" Automatically start script
"let generate_tags=1
" Displays taglist results in a vertical window:
"let Tlist_Use_Horiz_Window=0
" Shorter commands to toggle Taglist display
"nnoremap TT :TlistToggle<CR>
"map <F4> :TlistToggle<CR>
" Various Taglist diplay config:
"let Tlist_Use_Right_Window = 1
"let Tlist_Compact_Format = 1
"let Tlist_Exit_OnlyWindow = 1
"let Tlist_GainFocus_On_ToggleOpen = 1
"let Tlist_File_Fold_Auto_Close = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: Project
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:proj_window_width = 40
let g:proj_flags = "imsgt"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: Pylint
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Prevents Pylint to becalled each time a buffer is saved
let g:pylint_onwrite = 0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: Buftabs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if ! &diff
set laststatus=2
"set statusline=%{buftabs#statusline()}%<%=%-16(%h%m%r%)%-12.(%l,%c%)\ %P
let g:buftabs_in_statusline = 0
let g:buftabs_only_basename = 1
let g:buftabs_marker_start = '['
let g:buftabs_marker_end = ']'
let g:buftabs_separator = ' '
let g:buftabs_marker_modified = ''
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: Lightlime
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive' ], [ 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}',
\ 'fugitive': '%{exists("*fugitive#head")?" ".fugitive#head():""}',
\ 'filename': '[%n] %f'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype != "help" && &readonly)',
\ 'modified': '(&filetype != "help" && (&modified || !&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && "" != fugitive#head())'
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: ACP
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:acp_enableAtStartup = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: CtrlP
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ctrlp_map = '<c-p>'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: Airline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline_theme = "powerlineish"
"let g:airline_theme_patch_func = 'AirlineThemePatch'
function! AirlineThemePatch(palette)
if g:airline_theme == 'powerlineish'
for colors in values(a:palette.normal)
let colors[3] = 245
endfor
endif
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN: VimWiki
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:vimwiki_list = [
\ {'path': '~/Documents/vimwiki/work', 'list_margin': 2},
\ {'path': '~/Documents/vimwiki/perso', 'list_margin': 2},
\ {'path': '~/Documents/vimwiki/copro', 'list_margin': 2}
\]
let g:vimwiki_hl_headers = 1
let g:vimwiki_hl_cb_checked = 2
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Key mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" <Leader> is "\"... but on azerty keyboard it better to use "," wich is
" more accessible
let mapleader = ","
let maplocalleader = ","
" Backspace key mapping
set backspace=indent,eol,start
" Windows move mappings
set splitbelow
set splitright
" Alt to buffer mapping
nnoremap <leader>" :buffer 1<cr>
nnoremap <leader>« :buffer 2<cr>
nnoremap <leader>» :buffer 3<cr>
nnoremap <leader>( :buffer 4<cr>
nnoremap <leader>) :buffer 5<cr>
nnoremap <leader>@ :buffer 6<cr>
nnoremap <leader>+ :buffer 7<cr>
nnoremap <leader>- :buffer 8<cr>
nnoremap <leader>/ :buffer 9<cr>
nnoremap <leader>* :buffer 10<cr>
nnoremap <leader>= :buffer 11<cr>
nnoremap <leader>% :buffer 12<cr>
nnoremap <leader><PageUp> :bfirst<cr>
nnoremap <leader><PageDown> :blast<cr>
map <silent> <C-Down> <C-w>j
map <silent> <C-Up> <C-w>k
map <silent> <C-Right> <C-w>l
map <silent> <C-Left> <C-w>h
map <silent> <C-q> <C-w>q
map <silent> <C-m> <C-w>_
"map <C-S-Down> <C-w>J
"map <C-S-Up> <C-w>K
"map <C-S-Right> <C-w>L
"map <C-S-Left> <C-w>H
map <silent> <S-Right> :bnext<cr>
map <silent> <S-Left> :bprev<cr>
map <silent> gt :bnext<cr>
map <silent> gT :bprev<cr>
map <silent> <C-k> :bclose<cr><c-w>l
set winaltkeys=no
map <silent> <M-Up> :3wincmd +<cr>
map <silent> <M-Down> :3wincmd -<cr>
map <silent> <M-Right> :3wincmd ><cr>
map <silent> <M-Left> :3wincmd <<cr>
map <silent> <M-r> :wincmd x<cr>
" Folding based on indent
"set foldmethod=indent
nnoremap <space> za
vnoremap <space> zf
" Easy indentation in visual mode
" This keeps the visual selection active after indenting.
" Usually the visual selection is lost after you indent it.
vmap > >gv
vmap < <gv
" Searches and highlight word under cursor
nnoremap <silent> <Leader>s :set invhls<cr>:exec "let @/='\\<".expand("<cword>")."\\>'"<cr>
" Enable or disable indentation guides
nnoremap <silent> <Leader>i :IndentGuidesToggle<CR>
" Enable or disable taglist window
nnoremap <silent> <F9> :TagbarToggle<CR>
nnoremap <silent> tt :TagbarToggle<CR>
" Toggles gundo
nnoremap <silent> <Leader>g :GundoToggle<CR>
" Go to next mark
nnoremap <silent> <Leader>n ]'
nnoremap <silent> <Leader>N ['
" Fuzzy buffer search
nnoremap <silent> <leader>d :CtrlPBuffer<CR>
" Enable or disable show marks
let g:showmarks_toggled = 0
function! ToggleShowMarks()
if g:showmarks_toggled == 0
silent DoShowMarks!
let g:showmarks_toggled = 1
else
silent NoShowMarks!
let g:showmarks_toggled = 0
endif
endfunction
command! ToggleShowMarks call ToggleShowMarks()
nnoremap <silent> <Leader>m :ToggleShowMarks<CR>
" Mouse and copy/paste control
if has("gui_running")
if has("win32")
noremap <Silent> <S-Insert> "+y
noremap <Silent> <C-Insert> "+gP
else
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>
endif
set mouse=
endif
" Enable or disable line number
let g:nu_toggled = 0
function! ToggleNu()
if g:nu_toggled == 0
silent set number
let g:nu_toggled = 1
else
silent set nonumber
let g:nu_toggled = 0
endif
endfunction
command! ToggleNu call ToggleNu()
"nnoremap <Silent> <Leader>n :ToggleNu<CR>
" Saves current vim session
nnoremap <Silent> <Leader>b :mksession! ~/Session.vim<CR>
" Enable or disable ACP autocompletion module
let g:acp_toggled = 0
function! AcpToggle()
if g:acp_toggled == 0
silent AcpEnable
let g:acp_toggled = 1
else
silent AcpDisable
let g:acp_toggled = 0
endif
endfunction
command! AcpToggle call AcpToggle()
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
" Swap windows buffers
let g:markedWinNum = -1
function! WindowSwap()
if g:markedWinNum < 0
call MarkWindowSwap()
echo "Window marked for swap"
else
call DoWindowSwap()
let g:markedWinNum = -1
endif
endfunction
function! MarkWindowSwap()
let g:markedWinNum = winnr()
endfunction
function! DoWindowSwap()
let curNum = winnr() "Mark destination
let curBuf = bufnr( "%" )
exe g:markedWinNum . "wincmd w"
let markedBuf = bufnr( "%" ) "Switch to source and shuffle dest->source
"Hide and open so that we aren't prompted and keep history
exe 'hide buf' curBuf
"Switch to dest and shuffle source->dest"
exe curNum . "wincmd w"
"Hide and open so that we aren't prompted and keep history"
exe 'hide buf' markedBuf
endfunction
nmap <silent> <S-Up> :call MarkWindowSwap()<CR>
nmap <silent> <S-Down> :call DoWindowSwap()<CR>
"nmap <silent> <S-Up> :call WindowSwap()<CR>
" Togles lines wrap
noremap <silent> <Leader>w :call ToggleWrap()<CR>
function ToggleWrap()
if &wrap
echo "Wrap OFF"
setlocal nowrap
set virtualedit=all
silent! nunmap <buffer> <Up>
silent! nunmap <buffer> <Down>
silent! nunmap <buffer> <Home>
silent! nunmap <buffer> <End>
silent! iunmap <buffer> <Up>
silent! iunmap <buffer> <Down>
silent! iunmap <buffer> <Home>
silent! iunmap <buffer> <End>
else
echo "Wrap ON"
setlocal wrap linebreak nolist
set virtualedit=
setlocal display+=lastline
noremap <buffer> <silent> <Up> gk
noremap <buffer> <silent> <Down> gj
noremap <buffer> <silent> <Home> g<Home>
noremap <buffer> <silent> <End> g<End>
inoremap <buffer> <silent> <Up> <C-o>gk
inoremap <buffer> <silent> <Down> <C-o>gj
inoremap <buffer> <silent> <Home> <C-o>g<Home>
inoremap <buffer> <silent> <End> <C-o>g<End>
endif
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Loads bepo key mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"source ~/.vim/bepo.vim
"set langmap=ba,éz,pe,or,èt,çy,vu,di,lo,fp,j^,z$,aq,us,id,ef,\,g,ch,tj,sk,nl,rm,mù,^*,ê<,àw,hx,yc,.v,kb,'n,q\,,g;;,x:,w!,BA,ÉZ,PE,OR,ÈT,ÇY,VU,DI,LO,FP,J¨,Z£,AQ,US,ID,EF,?G,CH,TJ,SK,NL,RM,M%,!*,Ê>,ÀW,HX,YC,:V,KB,\\;N,QG,G.,X/,W§,@œ,_&,"é,«",»',((,)-,+è,-_,*ç,/à,=),%=,$Œ,^°,µ+,#“,{´,}~,<#,>{,[[,]|,±`,¬\,×^,÷@,¯],%}
if filereadable($HOME . "/.vimrc.local")
source $HOME/.vimrc.local
endif