forked from fvisin/vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
785 lines (671 loc) · 30.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
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
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
" Hotkeys summary (note <leader> == ",")
" ----------------
" <leader> d Rope goto definition (jedi through rope or YouCompleteMe)
" <leader> s YouCompleteMe goto declaration
" <Ctrl>-o Jump back
" K Show documentation with jedi plugin
" Ctrl-l Creates documentation of highlighted 'def' or 'class'
" def + <ctrl-space> Create snippet for new function
" ipdb + <ctrl-space> Sets trace
" <leader> ig Toggle visualization of indent guides
" :Ack foo [{dir}] Search recursively
" <leader> tl opens TaskList (shows every todo)
" <leader> r Deletes the word under the cursor and enters insert mode. When insert mode is left, it will rename all the occurrencies
" <leader> n List of all names which point to the definition of the name under the cursor
" [[ Jump on previous class or function (normal, visual, operator modes) (jedi through rope)
" ]] Jump on next class or function (normal, visual, operator modes) (jedi through rope)
" [M Jump on previous class or method (normal, visual, operator modes) (jedi through rope)
" ]M Jump on next class or method (normal, visual, operator modes) (jedi through rope)
" Ctrl-W Ctrl-W Go to next error
" <leader> tt open Tagbar
" <C-p> file search
" <leader>s content search
" <leader>r file_rec/async
" <leader>f file
" <leader>m file_mru
" <leader>o outline
" <leader>y history/yank
" <leader>b buffer
"
" <F2> Toggle paste mode
" <F4> Navigate through undos (with Gundo)
" <F6> Autofix PEP8 errors - Note it automatically saves the file!!!
" Ctrl-g Shows the current filename
"
"
" <F8> Enable spell-check
" <F9> Toggle git gutter
" z View spelling suggestions for the mispelled word
" zg Add the current word to the dictionary
" zug Remove the current word from the dictionary
" ]s Next mispelled word
" [s Prev mispelled word
" gqq Autowrap the current line
" Plugins description
" -------------------
" * ack: search recursively with :Ack [options] {pattern} [{directories}]
" * autopep8: format code according to PEP8 specifications
" * gundo: diff with last saves
" * neoyank.vim: used by unite to show yank history
" * pydocstring: inserts templates for the documentation
" * snipmate: allows to insert snippets with <snippet_name> + <Tab>
" * snippets: snipmate custom snippets directory
" * solarized: solarized theme for vim
" * supertab: provides autocomplete with TAB
" * syntastic: syntax check in vim (a syntax checker has to be installed)
" * tagbar: provides an easy way to browse the tags of the current file and get an overview of its structure.
" * tasklist: lists of every todo in the code
" * tomtom/tlib_vim: (snipmate requirement)
" * unite-outline: used by unite to display outline
" * unite.vim: search and display information from arbitrary sources like files, buffers, ..
" * MarcWeber/vim-addon-mw-utils: (snipmate requirement)
" * vim-gitgutter: show git diff in the gutter (sign column)
" * vim-indent-guides: adds indentation guides
" * vim-markdown: syntax highlighting for markdown
" * vim-pep8-text-width: wraps text at 79 char for code and 72 for comments (PEP8 specifications)
" * vimproc-vim: used by unite to speed up search
" * vim-repeat: enhance vim's last command repetition with '.'
" * vim-yaml: indentation settings for yaml files
" * YouCompleteMe: autocompletion + jump to definition (jedi alternative)
" Disabled
" * jedi-vim: does everything :) --> too slow
" * pydoc: shows the documentation of the current command
" * python-mode: apparently not compatible with jedi-vim
" * vim-easyclip: enhance copy and paste
" * vim-latex: adds autocomplete and some other features for latex
" Also, the indent directory contains a script to automatically indent python
" Notes
" * make sure .viminfo is owned by your user
" * to select text with mouse keep shift pressed
" * to have code completion in an environment, set VIRTUAL_ENV=/path/to/the/environment
" * To add or remove plugins, edit .vimrc, (re)open vim, run :PluginInstall or
" :PluginClean. See ':h vundle' for more details or Vundle wiki for FAQ
" Vundle + plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible " be iMproved, required
filetype off " required
nnoremap gm m
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin() " you can also pass a path where Vundle should install plugins
" The installed bundles
Plugin 'gmarik/Vundle.vim' " let Vundle manage Vundle (required!)
Plugin 'mileszs/ack.vim'
Plugin 'hhatto/autopep8'
Plugin 'sjl/gundo.vim', {'name': 'gundo'}
" Plugin 'davidhalter/jedi-vim'
Plugin 'LaTeX-Box-Team/LaTeX-Box'
Plugin 'Shougo/neoyank.vim'
Plugin 'heavenshell/vim-pydocstring', {'name': 'pydocstring'}
" Plugin 'garbas/vim-snipmate', {'name': 'snipmate'}
Plugin 'fvisin/vim-snippets.git', {'name': 'snipmate-snippets'} " fork of garbas/vim-snipmate without annoying . snippet
Plugin 'sirver/UltiSnips'
Plugin 'altercation/vim-colors-solarized', {'name': 'solarized'}
Plugin 'ervandew/supertab'
Plugin 'scrooloose/syntastic'
Plugin 'majutsushi/tagbar'
Plugin 'vim-scripts/TaskList.vim', {'name': 'tasklist'}
" Plugin 'tomtom/tlib_vim' " (snipmate requirement)
Plugin 'h1mesuke/unite-outline'
Plugin 'Shougo/unite.vim'
" Plugin 'MarcWeber/vim-addon-mw-utils' " (snipmate requirement)
" Plugin 'svermeulen/vim-easyclip'
Plugin 'airblade/vim-gitgutter'
Plugin 'nathanaelkane/vim-indent-guides'
" Plugin 'vim-latex/vim-latex'
Plugin 'plasticboy/vim-markdown'
Plugin 'jimf/vim-pep8-text-width'
Plugin 'Shougo/vimproc.vim' " used by unite
Plugin 'tpope/vim-repeat'
Plugin 'avakhov/vim-yaml'
Plugin 'Valloric/YouCompleteMe'
" Plugin 'fs111/pydoc.vim', {'name': 'pydoc'}
" Plugin 'klen/python-mode' " Apparently not compatible with jedi-vim
" TODO: C++
" http://www.zwiener.org/vimautocomplete.html
call vundle#end() " required
filetype plugin indent on " required
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
" Set to auto read when a file is changed from the outside
set autoread
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Don't redraw while executing macros (good performance config)
set lazyredraw
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
let mapleader=","
" Timeout after leader key
set tm=500
" Prevent ctrl-z from closing vim
map <C-Z> <Nop>
" Set F2 to paste mode toggle
set pastetoggle=<F2>
"Open new split panes to right and bottom
set splitbelow
set splitright
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Scroll to keep the cursor n lines above/under the end/top of the page
set so=7
" Turn on the WiLd menu (autocomplete :commands)
set wildmenu
set wildmode=longest:list,full
" Show matching brackets
set showmatch
" Show incomplete commands
set showcmd
" How many tenths of a second to blink when matching brackets
set mat=3
" Enable syntax highlighting for .bash_aliases
au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_aliases,.bash_profile*,.bash_logout*,*.bash,*.ebuild set filetype=sh
au BufNewFile,BufRead *.txt set filetype=rest
"call SetFileTypeSH("bash")
"set laststatus=2 --> status is very useful, but wastes one line
"set statusline="%f%m%r%h%w [%Y] [0x%02.2B]%< %F%=%4v,%4l %3p%% of %L" " Show filename in status bar
" set hid " A buffer becomes hidden when it is abandoned
" set magic " For regular expressions turn magic on
" Always show current position
set ruler
" show line and percentage (default)
set rulerformat=%l,%c%V%=%P
" Height of the command bar
set cmdheight=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Search options
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Highlight results of search
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Do case insensitive matching
set ignorecase
" Search case sensitive only if you type uppercase
set smartcase
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Errors and warnings notifications
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Syntax highlight and colors
syntax on " Enable syntax highlighting
filetype on " Try to detect filetypes
filetype plugin indent on " Turn on filetype-specific indenting modes and plugins
let python_highlight_all=1 " Extra highlights
" Colors
" set term=xterm
set t_Co=256 " Force VIM to use 256 colors even if terminal doesn't
colo solarized " use the solarized color scheme
set background=dark " use the dark background scheme
" Highlight text that is longer than 80 characters
augroup vimrc_autocmds
autocmd BufEnter * highlight OverLength ctermbg=0
autocmd BufEnter * match OverLength /\%80v.*/
augroup END
"if exists('+colorcolumn') " Draw a yellow column after 80 lines and after 120
" let &colorcolumn="80,".join(range(120,999),",")
" hi ColorColumn ctermfg=yellow ctermbg=232 guibg=#2c2d27
"endif
" Error and warning highlight colors
hi Search ctermfg=237 ctermbg=178 " Colors for search
" *** No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set autoindent " New line inherits indentation from the previous line
set nosmartindent " Avoid losing indentation when inserting '#'
set cindent " Should be smarter than smartindent. Autoindents after brackets, ..
set tabstop=4 " 1 Tab = 4 spaces
set softtabstop=4 " Number of spaces for tab in insert mode
set shiftwidth=4 " 1 Tab = 4 spaces
set smarttab " interpret Tab depending on where is the cursor
set expandtab " Substitute tabs with spaces
set ai " Auto indent: copy indentation from previous line
set wrap " Wrap lines
" set textwidth=80 " Set line break at 80 characters --> vim-pep8-text-width
" set formatoptions+=t " Enable automatic text wrapping --> vim-pep8-text-width
" set si " Smart indent: automatically insert one extra level in some cases
" set listchars=tab:\|\<Space> " how to highlight tabs
" set number " Show line numbers
" set lbr " Set line break
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nobackup
set nowb
set noswapfile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Personalized key bindings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Redefine W and Q because c'mon, they are not even a command!
command WQ wq
command Wq wq
command W w
command Q q
" Move between windows with alt+arrows
nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Left> :wincmd h<CR>
nmap <silent> <A-Right> :wincmd l<CR>
" Map jj to <Esc>
imap jj <Esc>
" Map ctrl-W to next error
nmap <C-W><C-W> :lnext<CR>
" When in normal mode, press Space followed by the character that you want to insert.
:nnoremap <Space> i_<Esc>r
" Disable highlight when <leader><cr> is pressed
map <silent> <leader><cr> :noh<cr>
" Activate spell check
noremap <F8> :set spell spelllang=en_us <CR>
" Auto spell check for tex and markdown
autocmd FileType latex,tex,md,markdown setlocal spell
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Hacks
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Strip trailing whitespace off all lines every time you save a .py or .pyx file
function! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre *.py,*.pyx,*.tex :call <SID>StripTrailingWhitespaces()
" Delete trailing white space on save
func! DeleteTrailingWS()
exe "normal gmz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
autocmd BufWrite *.coffee :call DeleteTrailingWS()
" Jump to the last position when reopening a file (NB: .viminfo should be owned by your user)
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" Vim scrolling
set mouse=a
"set ttymouse=xterm
" Code completition in virtual environments
py << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
sys.path.insert(0, project_base_dir)
#activate_this = os.path.join(project_base_dir,
#'bin/activate_this.py')
#execfile(activate_this, dict(__file__=activate_this))
EOF
" => Autopep8 (autofix pep8 errors)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
noremap <F6> :!autopep8 --in-place --aggressive --aggressive %
" => Easyclip (Paste with buffer, substitute, ..)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" let g:EasyClipUseCutDefaults=0 " disable default bindings (do not override m)
" nmap d <Plug>MoveMotionPlug " add the text cut with d and dd to the yank buffer
" xmap d <Plug>MoveMotionXPlug
" nmap dd <Plug>MoveMotionLinePlug
" let g:EasyClipEnableBlackHoleRedirect=0 " keep d behaviour intact
"let g:EasyClipUseSubstituteDefaults=1
" => Gundo (navigate through undo list)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <F4> :GundoToggle<CR>
" => Jedi-vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" (refer to https://github.com/davidhalter/jedi-vim#faq)
autocmd FileType python setlocal completeopt-=preview "Disable docstring window popup
let g:jedi#completions_command='<C-Space>' "(def:<C-N>)
let g:jedi#popup_on_dot = 0 "(def:1)
let g:jedi#show_call_signatures = 2 " 0=disabled, 1=popup in the buffer (fucks up undos), 2=popup in command line (def: 1)
let g:jedi#smart_auto_mappings=0 "fancy things like automatically add 'import' after from something (def:1)
" let g:jedi#auto_close_doc "autoclose doc when insert mode is left(def:1)
" let g:jedi#documentation_command "(def:K)
" let g:jedi#completions_enabled "(def:1)
" let g:jedi#force_py_version "Force python2 or python3 (def:auto)
" let g:jedi#goto_command "try to find the original definition of the command under the cursor (def:<leader>d)
" let g:jedi#max_doc_height "(def:20)
" let g:jedi#popup_select_first = 0 "automatically select the first entry of the completion menu
" let g:jedi#rename_command "deletes the word currently under the cursor and puts Vim in insert mode. Upon leaving insert mode, jedi-vim then renames all occurences of the old variable (def:<leader>r)
" let g:jedi#usages_command "list of all names which point to the definition of the name under the cursor (def:<leader>n)
" let g:jedi#use_tabs_not_buffers "use tabs to go to a definition, etc (def: 0)
" let g:jedi#use_splits_not_buffers "use a split window instead of a buffer (def: 1, other: left, right, top, bottom, winwidth)
" => LatexBox
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" let g:LatexBox_latexmk_async=1 --> requires clientserver vim capability
let g:LatexBox_latexmk_preview_continuously=1
" => Pydocstring
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:pydocstring_templates_dir = $HOME."/.vim/pydocstring-templates/"
" => Supertab
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" au FileType python set omnifunc=pythoncomplete#Complete " This breaks Jedi
let g:SuperTabDefaultCompletionType = "context"
" set completeopt=menuone,longest,preview # kyle
let g:SuperTabDefaultCompletionType = "<c-x><c-o>" " always use omni completion (i.e. Jedi)
" => Syntastic (Syntax check)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" You can run checkers explicitly by calling :SyntasticCheck <checker
let g:syntastic_python_checkers = ['flake8'] "use one of the following checkers:
" flake8, pyflakes, pylint, python (native checker)
let g:syntastic_enable_highlighting = 1 "highlight errors and warnings
let g:syntastic_style_error_symbol = ">>" "error symbol
let g:syntastic_warning_symbol = ">>" "warning symbol
let g:syntastic_check_on_open = 1
let g:syntastic_always_populate_loc_list = 1 "populate error list so that we can cycle through them
"let g:syntastic_auto_loc_list=1 "open list of errors
let g:syntastic_loc_list_height = 5 "list length
let g:syntastic_auto_jump = 0 "do not jump to errors when detected
let g:syntastic_stl_format = '[%E{Err: %fe #%e}%B{, }%W{Warn: %fw #%w}]' "show number of errors and warnings
"set the colour of errors and warnings
hi SpellBad ctermfg=235 ctermbg=166 " errors line
" hi error ctermfg=237 ctermbg=178 " errors sign
hi SyntasticErrorSign ctermfg=166 cterm=bold " style errors sign
" hi error ctermfg=darkblue ctermbg=yellow " errors sign
" hi SyntasticErrorSign ctermfg=darkblue ctermbg=yellow " style errors sign
" => Tasklist
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>tl <Plug>TaskList
" => Tagbar
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <leader>tt :TagbarToggle<CR>
" => Unite
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:unite_data_directory = '/tmp/vim/unite/'
let g:unite_abbr_highlight = 'Keyword'
nnoremap <C-p> :Unite file_rec/async<cr> " File search
nnoremap <leader>s :Unite grep:.<cr> " Content search
let g:unite_source_history_yank_enable = 1
call unite#filters#matcher_default#use(['matcher_fuzzy'])
nnoremap <silent><leader>f :<C-u>Unite -buffer-name=files file<cr>
nnoremap <silent><leader>r :<C-u>Unite -buffer-name=files file_rec/async:!<cr>
nnoremap <silent><leader>m :<C-u>Unite -buffer-name=mru -start-insert file_mru<cr>
nnoremap <silent><leader>o :<C-u>Unite -buffer-name=outline outline<cr>
nnoremap <silent><leader>y :<C-u>Unite -buffer-name=yank history/yank<cr>
nnoremap <silent> <leader>b :<C-u>Unite buffer bookmark<CR>
" Custom mappings for the unite buffer
autocmd FileType unite call s:unite_settings()
function! s:unite_settings()
" Play nice with supertab
let b:SuperTabDisabled=1
" Enable navigation with control-j and control-k in insert mode
imap <buffer> <C-j> <Plug>(unite_select_next_line)
imap <buffer> <C-k> <Plug>(unite_select_previous_line)
endfunction
" => Vim gutter
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <F9> :GitGutterToggle<CR>
" => Vim indent guides
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" toggled with <Leader> ig
let g:indent_guides_auto_colors = 0 " set colors manually
hi IndentGuidesOdd ctermbg=darkgrey
hi IndentGuidesEven ctermbg=darkgrey
let g:indent_guides_start_level=2 " start showing indentation from the 2 level
let g:indent_guides_guide_size=1 " dimension of the guide
let g:indent_guides_enable_on_vim_startup=0 "autostart
" => Vim markdown
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:vim_markdown_folding_disabled = 1
" DISABLED
" => Pydoc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Open docs with <leader>pw or <leader>pW
" let g:pydoc_highlight = 0 " Don't highlight word when open word definition
" => Python-mode
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Documentation
"let g:pymode_doc = 1
"let g:pymode_doc_key = 'K'
"let g:pymode_doc = 0
" set completeopt=menu " Prevent the docs window from automatically open
"Linting
"let g:pymode_lint = 0 " Disable linting: use syntastic
""let g:pymode_lint_checker = "pyflakes,pep8,pep257"
""let g:pymode_lint_write = 1 " Auto check on save (if modified)
""let g:pymode_lint_unmodified = 0 " Check even if unmodified
""let g:pymode_lint_signs = 1 " Place error signs
""let g:pymode_lint_ignore = "C901"
""let g:pymode_lint_cwindow = 1 "Auto open cwindow (quickfix) if any errors have been found
"
"" Automatically fix PEP8 errors in the current buffer:
"noremap <F8> :PymodeLintAuto<CR>
"
"" Support virtualenv detection
"let g:pymode_virtualenv = 1
"
"" Enable breakpoints plugin
"let g:pymode_breakpoint = 1
"let g:pymode_breakpoint_key = '<leader>b'
"let g:pymode_breakpoint_cmd = 'from IPython import embed; embed()'
"
"" Completion
"let g:pymode_rope_completion = 1 " Turn on code completion
"let g:pymode_rope_complete_on_dot = 0 " Turn off autocomplete on dot
"let g:pymode_rope_completion_bind = '<C-Space>' " Ctrl-space to complete
"let g:pymode_rope_autoimport = 1 " Autocomplete objects that have not been imported
"
"" Syntax highlighting
"let g:pymode_syntax = 1
"let g:pymode_syntax_all = 1
"let g:pymode_syntax_indent_errors = g:pymode_syntax_all
"let g:pymode_syntax_space_errors = g:pymode_syntax_all
"
"" Don't autofold code
"let g:pymode_folding = 0
"
"" Disable rope (refactoring)
"let g:pymode_rope = 0
" => Ropevim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Go to definition and rename all occurrencies
"map <leader>j :RopeGotoDefinition<CR>
"map <leader>r :RopeRename<CR>
" => Ulti-snips
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" " Map to space
" let g:UltiSnipsExpandTrigger="<nop>"
" inoremap <expr> <space> pumvisible() ? "<space>=UltiSnips#ExpandSnippetOrJump()<space>" : "\<space>"
let g:UltiSnipsExpandTrigger="<c-space>"
let g:UltiSnipsListSnippets="<c-tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-j>"
" let g:UltiSnipsJumpBackwardTrigger="<c-k>"
" => Vim latex
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Recommended in the documentation
" set grepprg=grep\ -nH\ $*
" filetype indent on
" let g:tex_flavor='latex'
" " TIP: if you write your \label's as \label{fig:something}, then if you
" " " type in \ref{fig: and press <C-n> you will automatically cycle through
" " " all the figure labels. Very useful!
" set iskeyword+=:
" let g:Imap_UsePlaceHolders=0 " disable placeholders
" let g:Tex_AutoFolding=0 " disable automatic folding. Can still fold with
" => YouCompleteMe
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Remap ycm keys to iterate over list, as by default are mapped to tab and
"" s-tab, which breaks ultisnips
"let g:ycm_key_list_select_completion=['<C-n>', '<Down>']
"let g:ycm_key_list_previous_completion=['<C-p>', '<Up>']
"let g:ycm_autoclose_preview_window_after_completion=1
"nnoremap <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
"nnoremap <leader>d :YcmCompleter GoTo<CR>
nnoremap <leader>d :YcmCompleter GoToDefinitionElseDeclaration<CR>
nnoremap <leader>s :YcmCompleter GoToDeclaration<CR>
let g:ycm_seed_identifiers_with_syntax = 0 " preseed with language syntax keywords
" AUTORELOAD BUFFERS WHEN FILES ARE CHANGED EXTERNALLY
" If you are using a console version of Vim, or dealing
" with a file that changes externally (e.g. a web server log)
" then Vim does not always check to see if the file has been changed.
" The GUI version of Vim will check more often (for example on Focus change),
" and prompt you if you want to reload the file.
"
" There can be cases where you can be working away, and Vim does not
" realize the file has changed. This command will force Vim to check
" more often.
"
" Calling this command sets up autocommands that check to see if the
" current buffer has been modified outside of vim (using checktime)
" and, if it has, reload it for you.
"
" This check is done whenever any of the following events are triggered:
" * BufEnter
" * CursorMoved
" * CursorMovedI
" * CursorHold
" * CursorHoldI
"
" In other words, this check occurs whenever you enter a buffer, move the cursor,
" or just wait without doing anything for 'updatetime' milliseconds.
"
" Normally it will ask you if you want to load the file, even if you haven't made
" any changes in vim. This can get annoying, however, if you frequently need to reload
" the file, so if you would rather have it to reload the buffer *without*
" prompting you, add a bang (!) after the command (WatchForChanges!).
" This will set the autoread option for that buffer in addition to setting up the
" autocommands.
"
" If you want to turn *off* watching for the buffer, just call the command again while
" in the same buffer. Each time you call the command it will toggle between on and off.
"
" WatchForChanges sets autocommands that are triggered while in *any* buffer.
" If you want vim to only check for changes to that buffer while editing the buffer
" that is being watched, use WatchForChangesWhileInThisBuffer instead.
"
command! -bang WatchForChanges :call WatchForChanges(@%, {'toggle': 1, 'autoread': <bang>0})
command! -bang WatchForChangesWhileInThisBuffer :call WatchForChanges(@%, {'toggle': 1, 'autoread': <bang>0, 'while_in_this_buffer_only': 1})
command! -bang WatchForChangesAllFile :call WatchForChanges('*', {'toggle': 1, 'autoread': <bang>0})
" WatchForChanges function
"
" This is used by the WatchForChanges* commands, but it can also be
" useful to call this from scripts. For example, if your script executes a
" long-running process, you can have your script run that long-running process
" in the background so that you can continue editing other files, redirects its
" output to a file, and open the file in another buffer that keeps reloading itself
" as more output from the long-running command becomes available.
"
" Arguments:
" * bufname: The name of the buffer/file to watch for changes.
" Use '*' to watch all files.
" * options (optional): A Dict object with any of the following keys:
" * autoread: If set to 1, causes autoread option to be turned on for the buffer in
" addition to setting up the autocommands.
" * toggle: If set to 1, causes this behavior to toggle between on and off.
" Mostly useful for mappings and commands. In scripts, you probably want to
" explicitly enable or disable it.
" * disable: If set to 1, turns off this behavior (removes the autocommand group).
" * while_in_this_buffer_only: If set to 0 (default), the events will be triggered no matter which
" buffer you are editing. (Only the specified buffer will be checked for changes,
" though, still.) If set to 1, the events will only be triggered while
" editing the specified buffer.
" * more_events: If set to 1 (the default), creates autocommands for the events
" listed above. Set to 0 to not create autocommands for CursorMoved, CursorMovedI,
" (Presumably, having too much going on for those events could slow things down,
" since they are triggered so frequently...)
function! WatchForChanges(bufname, ...)
" Figure out which options are in effect
if a:bufname == '*'
let id = 'WatchForChanges'.'AnyBuffer'
" If you try to do checktime *, you'll get E93: More than one match for * is given
let bufspec = ''
else
if bufnr(a:bufname) == -1
echoerr "Buffer " . a:bufname . " doesn't exist"
return
end
let id = 'WatchForChanges'.bufnr(a:bufname)
let bufspec = a:bufname
end
if len(a:000) == 0
let options = {}
else
if type(a:1) == type({})
let options = a:1
else
echoerr "Argument must be a Dict"
end
end
let autoread = has_key(options, 'autoread') ? options['autoread'] : 0
let toggle = has_key(options, 'toggle') ? options['toggle'] : 0
let disable = has_key(options, 'disable') ? options['disable'] : 0
let more_events = has_key(options, 'more_events') ? options['more_events'] : 1
let while_in_this_buffer_only = has_key(options, 'while_in_this_buffer_only') ? options['while_in_this_buffer_only'] : 0
if while_in_this_buffer_only
let event_bufspec = a:bufname
else
let event_bufspec = '*'
end
let reg_saved = @"
"let autoread_saved = &autoread
let msg = "\n"
" Check to see if the autocommand already exists
redir @"
silent! exec 'au '.id
redir END
let l:defined = (@" !~ 'E216: No such group or event:')
" If not yet defined...
if !l:defined
if l:autoread
let msg = msg . 'Autoread enabled - '
if a:bufname == '*'
set autoread
else
setlocal autoread
end
end
silent! exec 'augroup '.id
if a:bufname != '*'
"exec "au BufDelete ".a:bufname . " :silent! au! ".id . " | silent! augroup! ".id
"exec "au BufDelete ".a:bufname . " :echomsg 'Removing autocommands for ".id."' | au! ".id . " | augroup! ".id
exec "au BufDelete ".a:bufname . " execute 'au! ".id."' | execute 'augroup! ".id."'"
end
exec "au BufEnter ".event_bufspec . " silent! :checktime ".bufspec
exec "au CursorHold ".event_bufspec . " silent! :checktime ".bufspec
exec "au CursorHoldI ".event_bufspec . " silent! :checktime ".bufspec
" The following events might slow things down so we provide a way to disable them...
" vim docs warn:
" Careful: Don't do anything that the user does
" not expect or that is slow.
if more_events
exec "au CursorMoved ".event_bufspec . " silent! :checktime ".bufspec
exec "au CursorMovedI ".event_bufspec . " silent! :checktime ".bufspec
end
augroup END
let msg = msg . 'Now watching ' . bufspec . ' for external updates...'
end
" If they want to disable it, or it is defined and they want to toggle it,
if l:disable || (l:toggle && l:defined)
if l:autoread
let msg = msg . 'Autoread disabled - '
if a:bufname == '*'
set noautoread
else
setlocal noautoread
end
end
" Using an autogroup allows us to remove it easily with the following
" command. If we do not use an autogroup, we cannot remove this
" single :checktime command
" augroup! checkforupdates
silent! exec 'au! '.id
silent! exec 'augroup! '.id
let msg = msg . 'No longer watching ' . bufspec . ' for external updates.'
elseif l:defined
let msg = msg . 'Already watching ' . bufspec . ' for external updates'
end
let @"=reg_saved
endfunction
" Options
let autoreadargs={'autoread':1}
execute WatchForChanges("*",autoreadargs)