aboutsummaryrefslogtreecommitdiff
path: root/vimrc-full
blob: 54504adc71a29bbca77b89120937472f582f99ca (plain)
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
786
787
788
789
790
791
792
793
794
795
" vim: tabstop=2 softtabstop=2 shiftwidth=2 textwidth=160 iskeyword+=\:

set encoding=utf-8            | " set up vim's cosole encoding (not file encoding, for which there is fileencoding=)
set t_Co=256                  | " required on some ssh sessions
" set background=light        | "
" set term=xtermc             | " may be required on solaris
" set term=xterm-256color
" set termguicolors

"=======================================================================================================================
" MATTER_OF_TASTE:
"=======================================================================================================================
set textwidth=120             | " better done with modeline
set ts=4 sts=4 sw=4 expandtab | " better done with a modeline

"=======================================================================================================================
" SETTINGS:
"=======================================================================================================================
set noautochdir               | " When on, Vim will change the current working directory
set breakindent               | " Every wrapped line will continue visually indented
set clipboard=unnamedplus     | " makes copy and paste work (autoselectplus might work as well)
set cmdheight=2               | " sets the command line's height
set complete+=d               | " scan current and included files for defined name or macro
set complete+=i               | " scan current and included files for completions
set concealcursor=nc          | " limits the display of concealed text to normal and command mode
set conceallevel=2            | " replace escaped chars by their utf-8 representation (useful for LaTeX)
set confirm                   | " asks 'do you want to save?'
set cpoptions+=P              | " makes :w filename set the current buffer to filename
set guicursor=a:block-blinkon100
set hidden                    | " allows switiching buffers even if the current buffer contains changes (displays +)
set hlsearch                  | " highlights all search matches (not as performant!)
set ignorecase smartcase      | " search with ignorecase by default, but use case sensitive search when one captical char is contained
set lazyredraw                | " disables redraw during macro exectution (improves performance)
set linebreak                 | " wrap long lines at char 'breakat', not inside words
set mouse=n                   | " allow mouse in normal mode only, so one can use the terminals c&p feature in insert mode
set mousemodel=popup          | " only in gvim: right click opens a popup-menu
set nocursorcolumn            | " turn visual cursor column off (improves performance)
set nocursorline              | " turn visual cursor line off (improves performance)
set nrformats+=alpha          | " allows CTRL-A & CTRL-X to increment and decrement letters, not just numbers
set nofoldenable              | " disable folding, because we have zi to toggle foldenable :)
set exrc                      | " enable exrc, a specific .exrc per project, which can contain usual .vimrc commands
set noequalalways             | " do not evenly size windows when opening new or closing old
set foldmethod=syntax         | " foldlevel: syntax, indent, manual
set foldcolumn=0              | " I think I don't need this second indicator
set foldclose=all             | " automatically fold, when the cursor leaves the folded area
set foldopen=block,hor,search | " when do we unfold?
set foldtext=Foldtext()       | "
set foldnestmax=1             | " top level folding only
set relativenumber            | " relative line numbers can speed up navigation
set noshowmode                | " because we are using some powerline derivat
set nostartofline             | " when scrolling: do not move the cursor to column 1
set notimeout ttimeout        | " improves performance but is known to cause problems on slow terminals
set ttimeoutlen=50            | " set esc key timeout in ms-
set nowrap                    | " but do not (by default) wrap long lines around
set number                    | " turn line numbers on/off (performance decreases when they are shown)
set pumheight=8               | " Determines the maximum number of items to show in the popup menu for
set path+=**                  | " allow recursive searches for files
set redrawtime=100            | " The time in milliseconds for redrawing the display.
" set restorescreen             | " restores the console after exiting vim
" set shada+=n~/.vim/shada      | " shada file to use
set scrolljump=5              | " how many lines get scrolled into view when cursor reaches the screens edge
set scrolloff=999             | " keeps cursor centered
set splitbelow                | " open new windows below the current one (i find that more intuitive)
set shiftround                | " indent/unindent snaps to multiple of shiftwidths
set shortmess+=I              | " don't give the intro message when starting Vim |:intro|.
set showcmd                   | " essential: show keys of combined commands in the lower right corner (BUT SLOW, makes cursor flickering)
set signcolumn=yes            | " auto=auto hide, yes=always, no=never show the column with error indicators
set showtabline=2             | " 0: never, 1: only if there are at least two tabs, 2:always
set winwidth=30               | " keep NERDTreeWindow at least this size
set winminwidth=30            | " (and all other windows, so TODO: watch out)
set tags+=../tags
" set textwidth=100             | " line length (80 used to be default, but...)
" set colorcolumn=              | " not used, because we have a :match directive for textwidth
set updatetime=80             | " updates the screen more often
set viminfo+=%                | " restore buffer list
set virtualedit=all           | " virtual edit should be default behaviour, because I don't see any reason against
set writedelay=0
set wildmenu                  | " use a menu in the command line
set wildmode=longest:full     | " do not preselect any entry and show all possible
"=======================================================================================================================

" START: LOADING PLUGINS
" ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
call plug#begin()

Plug 'tpope/vim-surround'             | " plugin makes cs"' inside a line replace " with '
Plug 'tpope/vim-fugitive'             | " the most complete GIT integration plugin
Plug 'godlygeek/tabular'              | " align code on a sign, like :Tab/=
Plug 'mhinz/vim-signify'              | " uses the sign column to indicate added, modified and removed lines
let g:signify_vcs_list = [ 'git' ]    | " use signify only with git (improves speed when loading buffers, see :h signify)
let g:signify_cursorhold_insert     = 1
let g:signify_cursorhold_normal     = 1
let g:signify_update_on_bufenter    = 0
let g:signify_update_on_focusgained = 1

" TESTING:                            | " plugins which I am currently trying...
" Plug 'rkitover/vimpager'
" found this command instead (use as PAGER):
" man -P 'nvim -R -u NORC -c":%!col -b" -c":set buftype=nowrite filetype=man" -' ls
"
" Plug 'Shougo/neocomplete.vim'       | " alternative to YouCompleteMe in some cases
" Plug 'tpope/vim-characterize'       | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values)

" Colorschemes:
Plug 'chriskempson/base16-vim'        | " not just one high quality color scheme (all named base16-*)
Plug 'ryanoasis/vim-devicons'         | " eye candy icons

" SCRATCH:                            | " Unobtrusive scratch window
Plug 'mtth/scratch.vim'
nnoremap <F2> :ScratchPreview<CR>

" VIM_ROOTER:                         | " Unobtrusive scratch window
" autocmd BufEnter * lcd %:p:h        | " Plugin vim-rooter get used instead (which is much more sane as well)
Plug 'airblade/vim-rooter'            | " makes :lcd changes to projects (git-)root (code-completion, gf, grep, find)
let g:rooter_targets="/,*.c,*.h"      | " only use rooter for C, not LaTeX or anything else
" Vim rooter can be replaced by :Gcd provided by fugitive :)

" BUFEXPLORER:                        | " a buffer to list all buffers has the advantage, that default /-searches work in there
Plug 'jlanzarotta/bufexplorer'
nnoremap <F12> :ToggleBufExplorer<CR>

" NERDTree: replaces NetRW, as long as it has so many bugs
Plug 'scrooloose/nerdtree'            | "
let NERDTreeIgnore                = ['\.aux$']
let NERDTreeCascadeSingleChildDir = 0 | " I don't get how one can use <m> to create files in that included directory
let NERDTreeChDirMode             = 0
let NERDTreeHiddenFirst           = 1
let NERDTreeMinimalUI             = 1
let NERDTreeShowBookmarks         = 1 | " show bookmarks by default (when opening for the first time)
let NERDTreeWinSize               = 40


" depending on if NERDTree has the focus:
nnoremap <expr>
      \ <leader><leader>
      \ bufwinnr("%")==g:NERDTree.GetWinNum() ? ':NERDTreeClose<CR>' : ':NERDTreeFind<CR>'
nnoremap <expr>
      \ <Tab>
      \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':bn<CR>'
nnoremap <expr>
      \ <S-Tab>
      \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':bp<CR>'
" close NERDTree if it is the last remaining window (taken from the official documentation)
" autocmd bufenter *
"       \ if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"

" Additional: ========================================.
Plug 'sheerun/vim-polyglot'                           " better syntax highlighting/indentation for multiple languages
let g:javascript_conceal_function             = "ƒ"
let g:javascript_conceal_null                 = "ø"
let g:javascript_conceal_this                 = "@"
let g:javascript_conceal_return               = "⇚"
let g:javascript_conceal_undefined            = "¿"
let g:javascript_conceal_NaN                  = "ℕ"
let g:javascript_conceal_prototype            = "¶"
let g:javascript_conceal_static               = "•"
let g:javascript_conceal_super                = "Ω"
let g:javascript_conceal_arrow_function       = "⇒"

Plug 'majutsushi/tagbar'                              " superseeds taglist-plus, which isn't maintained any more
let g:tagbar_autoclose   = 0
let g:tagbar_autofocus   = 1
let g:tagbar_autoshowtag = 1
let g:tagbar_compact     = 1
let g:tagbar_indent      = 0
let g:tagbar_foldlevel   = 99
nnoremap <leader>l :TagbarToggle<CR>|                 " bind TagBar to Hotkey Ctrl+L
nnoremap <F9> :TagbarToggle<CR>|                      " bind TagBar to Hotkey Ctrl+L


" AIRLINE: a fancy status line =========================================================================================
set laststatus=2                                        | " required by AirLine, without status line does not appear until a window split
set background=light

Plug 'itchyny/lightline.vim'
Plug 'taohex/lightline-buffer'

" lightline-buffer ui settings
" replace these symbols with ascii characters if your environment does not support unicode
let g:lightline_buffer_logo                     = '  '
let g:lightline_buffer_readonly_icon            = ''
let g:lightline_buffer_modified_icon            = '✭'
let g:lightline_buffer_git_icon                 = ' '
let g:lightline_buffer_ellipsis_icon            = '..'
let g:lightline_buffer_expand_left_icon         = '◀ '
let g:lightline_buffer_expand_right_icon        = ' ▶'
let g:lightline_buffer_active_buffer_left_icon  = ''
let g:lightline_buffer_active_buffer_right_icon = ''
let g:lightline_buffer_separator_icon           = ' '

" lightline-buffer function settings
let g:lightline_buffer_show_bufnr               = 1
let g:lightline_buffer_rotate                   = 0
let g:lightline_buffer_fname_mod                = ':t'
let g:lightline_buffer_excludes                 = ['vimfiler']
let g:lightline_buffer_maxflen                  = 30
let g:lightline_buffer_maxfextlen               = 3
let g:lightline_buffer_minflen                  = 16
let g:lightline_buffer_minfextlen               = 3
let g:lightline_buffer_reservelen               = 20

function! MyFiletype()
  if(exists('b:filetype'))
    return b:filetype
  else
    return &filetype
endfunction
autocmd BufEnter * let b:filetype = winwidth(0) > 70 ? (strlen(&filetype) ? WebDevIconsGetFileTypeSymbol() . ':' . &filetype : 'no ft') : ''

function! MyFileformat()
  return exists('b:fileformat') ? b:fileformat : &fileformat
endfunction
autocmd BufEnter * let b:fileformat = winwidth(0) > 70 ? WebDevIconsGetFileFormatSymbol() . ':' .  &fileformat : ''

function! MyBranchname()
  return exists('b:branchname') ? b:branchname : ''
endfunction
autocmd BufEnter * let b:branchname = winwidth(0) > 70 ? fugitive#statusline() : ''

let g:lightline = {
    \   'colorscheme': 'Tomorrow_Night_Bright',
    \   'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
    \   'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" },
    \   'active': {
    \     'left': [ [ 'mode', 'paste', 'readonly' ],
    \               [ 'gitbranch', 'absolutepath' ],
    \               [ 'tagbar' ] ],
    \     'right': [ [ 'lineinfo', 'percent' ],
    \                [ 'spell', 'fileencoding', 'fileformat', 'filetype' ] ],
    \   },
    \   'tabline': {
    \     'left': [ [ 'bufferinfo' ], [ 'bufferbefore', 'buffercurrent', 'bufferafter' ], ],
    \     'right': [ [ 'close' ], [ 'getcwd', 'gitbranch'] ],
    \   },
    \   'component': {
    \           'tagbar': '%{tagbar#currenttag("%s", "", "f")}',
    \   },
    \   'component_expand': {
    \     'buffercurrent': 'lightline#buffer#buffercurrent2',
    \   },
    \   'component_type': {
    \     'buffercurrent': 'tabsel',
    \   },
    \   'component_function': {
    \     'bufferbefore': 'lightline#buffer#bufferbefore',
    \     'bufferafter': 'lightline#buffer#bufferafter',
    \     'bufferinfo': 'lightline#buffer#bufferinfo',
    \     'filetype': 'MyFiletype',
    \     'fileformat': 'MyFileformat',
    \     'getcwd': 'getcwd',
    \     'gitbranch': 'fugitive#head'
    \   },
    \ }

" lightline#palette()

"    Plug 'vim-airline/vim-airline'                          | " beautification of the mode line
"    let g:airline_section_c                          = "%F" | " was: %F
"    let g:airline_detect_modified                    = 1    |
"    let g:airline_detect_paste                       = 0    |
"    let g:airline_exclude_preview                    = 0    |
"    let g:airline_inactive_collapse                  = 1    |
"    let g:airline_powerline_fonts                    = 1    |
"    let g:airline_skip_empty_sections                = 1    |
"    let g:airline_extensions                         = []   |
"
"    let g:airline#extensions#tabline#enabled         = 1    |
"    let g:airline#extensions#tabline#left_alt_sep    = ''   |
"    let g:airline#extensions#tabline#left_sep        = ''   |
"    let g:airline#extensions#tabline#right_alt_sep   = ''   |
"    let g:airline#extensions#tabline#right_sep       = ''   |
"    let g:airline#extensions#tabline#fnamemod        = ':t' | " let airline just show the filename without its path
"    let g:airline#extensions#tabline#disable_refresh = 1    | " refresh airline on bufadd ?
"    let g:airline#extensions#tabline#enabled         = 1    |
"    let g:airline#extensions#tabline#show_buffers    = 1    |
"    let g:airline#extensions#tabline#show_tabs       = 0    |
"    let g:airline#extensions#tabline#ignore_bufadd_pat = '\c\vgundo|undotree|vimfiler|tagbar|nerd_tree|preview|^$'
"
"    let g:airline_extensions#branch#enabled          = 1    |
"    let g:airline_extensions#whitespace#enabled      = 0    | " airlines whitespace check is slow :/
"    let b:airline_whitespace_checks                  = ['indent', 'trailing', 'long', 'mixed-indent-file']
"
"    if has('python')
"      let g:airline_extensions#syntastic#enabled     = 1    |
"      let g:airline_extensions#ycm#enabled           = 1    |
"    endif
"
"    let g:airline#extensions#tagbar#flags            = 'f'  | " even though the airline extension is off this controls :h tagbar-extend
"    let g:airline#extensions#tagbar#enabled          = 0    |
"
"    " AIRLINE_Theme:
"    Plug 'vim-airline/vim-airline-themes'                   | " airline themes to match any light and dark terminal using :AirlineTheme
"    let base16colorspace=256                                |
"    let g:airline_theme='base16'                            | " specifies which colorscheme should airline uses
"    let g:airline#themes#base16#constant             = 0    |
"    " let g:solarized_base16 = 1
"    " let g:airline_base16_improved_contrast = 1
"    " let g:airline_theme='badcat'                       | " specifies which colorscheme should airline uses
"    " let g:airline_theme='papercolor'                   | " specifies which colorscheme should ionirline uses

" Autocompleter: =====================================
if has("python")
  " YouCompleteMe: =====================================================================================================
  " Plug 'Valloric/MatchTagAlways'                           " highlights the closing tag/brace/...
  Plug 'Valloric/YouCompleteMe'
  Plug 'vim-scripts/dbext.vim'                       " dependency to allow db related completions
  let g:ycm_server_python_interpreter                = "python3"
  let g:ycm_add_preview_to_completeopt               = 1   " reuse existing preview window
  let g:ycm_autoclose_preview_window_after_insertion = 1
  let g:ycm_collect_identifiers_from_tags_files      = 0   " Let YCM read tags from Ctags file
  let g:ycm_seed_identifiers_with_syntax             = 1   " Completion for programming language's keyword
  let g:ycm_complete_in_comments                     = 1   " Completion in comments
  let g:ycm_complete_in_strings                      = 1   " Completion in string
  let g:ycm_error_symbol                             = '✖' " insert this as an error symbol in the gutter bar
  let g:ycm_min_num_of_chars_for_completion          = 1
  let g:ycm_use_ultisnips_completer                  = 1   " Default 1, just ensure
  let g:ycm_warning_symbol                           = '➔' " insert this as a warning symbol in the gutter bar
  let g:ycm_confirm_extra_conf                       = 0   " security is overrated
  let g:ycm_key_list_select_completion               = ['<Down>']
  let g:ycm_key_list_previous_completion             = ['<Up>']
  let g:ycm_global_ycm_extra_conf                    = '.ycm_extra_conf.py'
  let g:ycm_semantic_triggers                        = { 'c': [ 're!.' ] }
  let g:ycm_python_binary_path                       = 'python' " the python interpreter of choice (for code checking)
  " let g:ycm_disable_for_files_larger_than_kb         = 16384 " we have faaast computers, don't we?

  " disable <tab>-key for YCM so that it can be used with ultisnips
  let g:ycm_key_list_select_completion=[]
  let g:ycm_key_list_previous_completion=[]


  " SYNTASTIC: =========================================================================================================
  Plug 'scrooloose/syntastic'
  set statusline+=%#warningmsg#
  set statusline+=%{SyntasticStatuslineFlag()}
  let g:LatexBox_latexmk_preview_continuously = 1
  let g:LatexBox_viewer                       = "evince"
  let g:syntastic_always_populate_loc_list    = 1
  let g:syntastic_auto_loc_list               = 0
  let g:syntastic_check_on_open               = 1
  let g:syntastic_check_on_wq                 = 0
  " let g:syntastic_quiet_messages              = {"type":"style"}
  "
  " E221: multiple spaces before Operator
  let g:syntastic_python_flake8_args          = '--max-complexity=10 --max-line-length=120 --exclude venv --doctests --exit-zero --ignore=E221'
  " filter ( = do not display) style/formatting errors and warnings
  let g:syntastic_error_symbol                = '✖'
  let g:syntastic_style_error_symbol          = '✗'
  let g:syntastic_warning_symbol              = '➔'
  let g:syntastic_style_warning_symbol        = '≈'

  " ULTISNIPS: code snippet ==============================================================================================
  Plug 'honza/vim-snippets'                                     " dependency of ultisnips (see below)
  Plug 'SirVer/ultisnips'                        " replaces loremipsum (and many more)
  "let g:UltiSnipsExpandTrigger       = '<C-j>'| " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
  "let g:UltiSnipsJumpForwardTrigger  = '<C-j>'| " \
  "let g:UltiSnipsJumpBackwardTrigger = '<C-k>'| " \
  "let g:UltiSnipsListSnippets        = '<C-`>'| " YouCompleteMe includes those, so this isn't necessary
  "let g:UltiSnipsExpandTrigger       = '<leader><tab>'| " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
  "let g:UltiSnipsJumpForwardTrigger  = '<PageDown>'| " \
  "let g:UltiSnipsJumpBackwardTrigger = '<PageUp>'| " \
  "let g:UltiSnipsListSnippets        = '<leader><leader>'| " YouCompleteMe includes those, so this isn't necessary

  " Plug 'rhysd/vim-clang-format'
  Plug 'kana/vim-operator-user' " dependency, which allows overriding the = operator for indentation
  autocmd FileType c,cpp,objc map <buffer> = :pyf /usr/share/clang/clang-format.py<CR>
  " let g:clang_format#detect_style_file     = 1
  " autocmd FileType c,cpp,objc map <buffer> = <Plug>(operator-clang-format)

  " JEDI: ==============================================================================================================
  Plug 'davidhalter/jedi-vim'               " jedi gets used to display python function signatures
  let g:jedi#completions_enabled        = 0 " we do not need completions, because we have YouCompleteMe
  let g:jedi#show_call_signatures       = 1 " which sadly does not support signatures like jedi
  let g:jedi#show_call_signatures_delay = 0
  let g:jedi#auto_vim_configure         = 0
  let g:pymode_rope                     = 0 " https://github.com/davidhalter/jedi-vim/issues/163
  " autocmd FileType python jedi.preload_module('os', 'sys', 'math')
  " let g:pymode_options_max_line_length          = 120
  " let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301'
endif


call plug#end()                                       | " all plugins are getting loaded on this line, don't remove!
" ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
" END: LOADING PLUGINS


" COLORSCHEME:
" uses the default terminal background color as background (allows transparency)
function! ExtendColorTheme()
  " let g:colors_name=""
  " set background=light
  filetype on
  filetype plugin on
  filetype indent on

  syntax on                     | " enable syntax highlighting
  syntax sync minlines=60       | " how many preceding lines will be parsed? (has performance impact)
  " highlight Normal ctermbg=NONE ctermfg=black

  highlight! CursorLineNr cterm=inverse | " ctermbg=black ctermfg=NONE
  highlight! Pmenu ctermbg=LightYellow ctermfg=blue
  highlight! PmenuSel ctermbg=blue ctermfg=LightYellow cterm=bold

  highlight! link PmenuSbar Pmenu
  highlight! PmenuThumb cterm=inverse
  highlight! MoreMsg cterm=inverse
  highlight! link Folded LineNr
  highlight! Cursor guibg=green ctermbg=yellow
  highlight! link VertSplit LineNr
  highlight! SpellBad ctermbg=none
  highlight! SpecialKey ctermfg=19
  highlight! WhiteSpace ctermfg=19

  highlight! link TabLine LineNr
  highlight! TabLineSel ctermbg=blue ctermfg=black
  highlight! link TabLineFill LineNr
  highlight! Search ctermbg=12 ctermfg=0
endfunction
autocmd ColorScheme * call ExtendColorTheme()


if filereadable(expand("~/.config/base16-shell/colortest"))
  let g:base16_shell_path="~/.config/base16-shell/scripts"
endif

let base16colorspace=256
if filereadable(expand("~/.vimrc_background"))
  source ~/.vimrc_background
else
  colorscheme base16-phd
endif




"=======================================================================================================================
" GENERAL:
"=======================================================================================================================

if filereadable("/bin/bash")
  set shell=/bin/bash           | " many scripts rely on bash, but its path varies why it is commented out here
endif


"=======================================================================================================================
" SPELL_CHECKING:
"=======================================================================================================================
let g:spellfile_URL='http://ftp.vim.org/vim/runtime/spell'
set spell            | " enable spell checker
set spelllang=en,de  | " languages for the spell checker
set spellsuggest=10  | " how many words will z= suggest?
set thesaurus+=/home/max/.vim/thesaurus/php.txt

set dictionary=/usr/share/dict/cracklib-small
set complete+=k " make default completer <C-N> respect the dictionary

" set fillchars+=stlnc:\―       | "


if has('autocmd')
    " autocmd VimEnter * let &t_EI .= "\<Esc>[0 q"
    " autocmd VimEnter * let &t_SI = "\<Esc>]12;green\x7"
    autocmd VimLeave * silent !echo -ne "\033]112\007"
endif

"=======================================================================================================================
if has("multi_byte")
  scriptencoding utf-8       | " tell vim that we are using utf-8 here
  set encoding=utf-8         | " we need default utf-8 encoding to use cool chars as line break and so on (see below)
  set termencoding=&encoding | " once we use special chars we assume everybody uses a terminal supporting those

  set fillchars+=fold:\—     | "
  set fillchars+=vert:\│     | " cool vertical split char
  set fillchars+=diff:\      | " a whitespace gets used here

  set listchars=             | " initialize empty listchars
  set listchars+=extends:»   | " symbols used when using :set list (which displays non-printable chars)
  set listchars+=precedes:«  | " symbols used when using :set list (which displays non-printable chars)

  set listchars+=tab:⮁\      | " symbols used when using :set list (which displays non-printable chars)
  set listchars+=trail:·     | " symbols used when using :set list (which displays non-printable chars)
  " set listchars+=eol:↲     | " symbols used when using :set list (which displays non-printable chars)
  " set listchars+=space:·   | " symbols used when using :set list (which displays non-printable chars)
  set showbreak+=| " symbol used in the beginning of a wrapped line
  set list
end

if has('cscope') " compiled with cscope support?
  " http://vim.wikia.com/wiki/Cscope
  set cscopetag         | " CTRL-] uses cscope first, then ctags
  set cscopeverbose

  if has('quickfix')
    set cscopequickfix=s+,c+,d+,i+,t+,e+
  endif

  " cnoreabbrev csa cs add
  " cnoreabbrev csf cs find
  " cnoreabbrev csk cs kill
  " cnoreabbrev csr cs reset
  " cnoreabbrev css cs show
  " cnoreabbrev csh cs help
  let @c = ":cs find s <cword>"
endif

" GUI_VERSION:
if has("gui_running")
  set browsedir=buffer
  set toolbar+=text
  set guioptions+=eig
  set guioptions-=T   | " toolbar
  set guioptions+=c   | " use console dialogs instead of popups
  set guioptions+=a   | " autoselect: copy&paste using middleclick
  set guioptions-=m   | " remove menu
  set guioptions-=e   | " do not display tabs
  set guioptions-=L   | " do not show left scrollbar
  set guioptions-=r   | " do not show right scrollbar
  set winaltkeys=menu | " behave like other windows: ALT-key can be used to open the menu (and cannot be :remaped)
  set guifont=Dejavu\ Sans\ Mono\ for\ Powerline\ 12
  " set guifont=Droid\ Sans\ Mono\ for\ Powerline\ 12
" set selectmode=mouse,key,cmd  | " enters vim's select mode when pressing shift-left or shift-END
" set keymodel=startsel,stopsel | " makes shift-left, shift-right available for selecting text
endif

" NEOVIM_incompatible:
if !has('nvim')       | " settings which have been removed from neovim
  set ttymouse=xterm2
  set ttyscroll=100   | " improves speed for terminal vim, incomp. with nvim
  set ttyfast         | " improves speed for terminal vim (incomp. with nvim)
  " set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incomp. with nvim
  "
  let g:loaded_ruby_provider = 1 " disable ruby support
  let g:loaded_python_provider = 1  " disable pthon3
endif

if has("autocmd")
  set modeline                | " set variables specific to a file, like indentation by adding a comment
  " set default completion function in case YouCompleteMe cannot help
  set omnifunc=syntaxcomplete#Complete

  " automatically reload this file when it gets edited
  if !exists("*OnConfigChange")
      function OnConfigChange()
          autocmd! |" Remove all vimrc autocommands
          source $MYVIMRC
          exec lightline#colorscheme()
          exec lightline#update()
          " AirlineRefresh
      endfunction
      autocmd BufWritePost $MYVIMRC call OnConfigChange()
  endif

  augroup set_window_title " {
    " autocmd BufWinEnter quickfix setl statusline=%t
    " autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]"
    autocmd CursorHold * let &titlestring = "%t|".$USER."@".hostname().":%{expand(\"%:~:.:h\")}%=%y"
    set title
    " autocmd CursorHold * let &titlestring = "Vim (".airline#extensions#tagbar#currenttag().")"

    " set window title for screen(3)
    if &term == "screen"
      set t_ts=k
      set t_fs=\
    endif
    if &term == "screen" || &term == "xterm"
      set titlelen=40
      set title
    endif
  augroup END

  " hitting K over a keyword shows a help in a buffer.
  " Here we define the commands used to look those keywords up
  " as per file type...
  augroup filetype_specific
    autocmd FileType python setlocal keywordprg=pydoc
    autocmd FileType vim    setlocal keywordprg=:help |.
    autocmd FileType c,cpp  setlocal equalprg=clang-format
    autocmd FileType c,cpp  setlocal breakat-=-
    " autocmd FileType c,cpp  setlocal iskeyword-=_

    " the following helps to make file=/etc/something work with gf, but disallows filenames with an equal sign in them
    autocmd FileType conf   setlocal isfname-==

    " keyboard mapping for xml alike languages
    " Alt-Up : Move cursor up one tag
    " Alt-Down: Move cursor down one tag
    " leader-=: tidies currently selected tag and subtags and sorts attributes by name (alphabetically)
    autocmd Filetype html,htmldjango,xml
      \ :nnoremap
              \ <M-Down>
              \ :call search('^ *<', 'e')<CR>:nohlsearch<CR>|
      \ :nnoremap
              \ <M-Up>
              \ :call search('^ *<', 'eb')<CR>:nohlsearch<CR>|
      \ :nnoremap
              \ <leader>=
              \ vat:'<,'>!tidy -xml --wrap 0 --sort-attributes alpha 2>/dev/null<CR>vat=
  augroup END

  augroup ChangeIcon
    "if filereadable("/usr/bin/xseticon")
    "if filereadable("~/.vim/nvim.png")
    " autocmd VimEnter * silent :execute "!xseticon -id $WINDOWID ~/.vim/nvim.png"
    " autocmd VimLeave * silent :execute "!xseticon -id $WINDOWID /usr/share/icons/gnome/32x32/apps/xfce-terminal.png"
    "endif
    "endif
  augroup END

  if has('nvim')
    autocmd TermOpen term://* set nobuflisted
    " use default ESC key to leave insert mode in the internal terminal emulator
    tnoremap <Esc> <C-\><C-n>
  else
    augroup vimonly
      autocmd VimLeave * call system("echo -n $'" . escape(getreg(), "'") . "' | xsel -ib")
    augroup END
  endif

  " autocmd BufNewFile set nobuflisted
  " use the shada/viminfo file to return the cursor to where it was...
  function! ReturnCursor()
    if line("'\"") > 1 && line("'\"") <= line("$")
      exe "normal! g`\""
    endif
  endfunction
  autocmd! BufReadPost * call ReturnCursor()


  augroup ToggleQuickFix
    function! ToggleQuickFix()
      if exists("g:qwindow")
        lclose
        unlet g:qwindow
      else
        try
          lopen 10
          let g:qwindow = 1
        catch
          echo "No Errors found!"
        endtry
      endif
    endfunction
    function! QFixToggle(forced)
      if exists("g:qfix_win") && a:forced == 0
        cclose
        unlet g:qfix_win
      else
        copen 10
        let g:qfix_win = bufnr("$")
      endif
    endfunction

    nmap <script> <silent> <F3> :call ToggleQuickFix()<CR>
    nmap <script> <silent> <F4> :call QFixToggle(0)<CR>
  augroup END


  augroup extra_whitespace " {
    highlight ExtraWhitespace ctermbg=red ctermfg=white guibg=red
    " autocmd BufEnter * syn match ExtraWhitespace /\s\+$/
    autocmd BufEnter * match ExtraWhitespace /\s\+$/
  augroup END "}

  augroup CurrentFileName
    highlight CurrentFileName ctermbg=yellow guibg=yellow


    let @w = ":execute ':match ColorColumn /\\%>'.&textwidth.'v./' | :2match ExtraWhitespace /\\s\\+$/"
  " let @w = ":execute ':match ColorColumn /\\%>'.&textwidth.'v./'"
    " highlight the current files name inside the document...
    let @g = ":exe ':match CurrentFileName /'.escape(expand('%:t'), '.').'/'"
    " put the current files name after the cursor...
    let @f = ":exe ':normal a'.expand('%:t')"

    " grep all buffers for a given string and return result in a quickfix window
    let @q = ":cex [] | bufdo vimgrepadd /foo/g % | cw"

    " change to the current working directory (p like pwd)
    let @p = ":lcd %:p:h"

    let @l = ":let g:signify_vcs_cmds={'git': 'git diff --no-color --no-ext-diff -U0 HEAD^ -- %f'}|:SignifyRefresh"

    let @r = ":exe ':!nvr --servername /tmp/nvimsocket --remote % +'.line('.')|:stopinsert|:set readonly"


    " exec current line as a command, insert output of command (from: https://youtu.be/MquaityA1SM?t=35m45s)
    nnoremap Q !!$SHELL<CR>

    " autocmd BufEnter * @f
  augroup END

  " autocmd VimEnter * set nobuflisted
endif


" ======================================================================================================================
" SHORTCUTS: custom shortcuts
" inoremap <C-Space> <C-x><C-o>
" inoremap <C-@> <C-Space>

" Bind CTRL+Backspace to vims version (CTRL+W) in " <CR> insert mode (only works with gvim)
inoremap
      \ <C-Backspace>
      \ <C-W>

" INDENTATION: allows deindenting a selected block and keeps selection
vnoremap < <gv
vnoremap > >gv

" make shift-home select to the beginning of the line
nnoremap <s-home> v^
nnoremap <s-end> v$

nnoremap <s-down> vj
vnoremap <s-down> j
nnoremap <s-up> vk
vnoremap <s-up> k


" close current buffer with <leader>q...
nnoremap <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>.

nnoremap <silent> <F5> :make<CR>
nnoremap <silent> <F6> :silent syntax sync fromstart<CR>:nohlsearch<CR>:silent match<CR>:silent 2match<CR>:silent 3match<CR>
nnoremap <leader>r :syntax sync fromstart


" INSERT_MODE_MAPPINGS:
" default copy&paste insert key binding (just in insert mode, so it doesn't conflict
" with visual block mode)- would have been nice, but collides with c-w for digraphs
" inoremap <C-V> <C-R>+
"
inoremap <C-S> <C-O>:w<CR>

" NEOVIM_SPECIFIC:
if has('nvim') " only neovim...
  " shortcut \t opens a terminal in a horizontal split
  nnoremap <leader>t :new +terminal<CR>
endif

" ======================================================================================================================
" Deprecated with this configuration, but still useful when deactivating some Plugins

" NETRW: obsolete with NERDTree
let g:netrw_alto          = 0       | " open files on the right
let g:netrw_altv          = 1       | " open files on the right
let g:netrw_banner        = 0       | " display help messages?
let g:netrw_browse_split  = 4       | " 4=open in previous window
let g:netrw_fastbrowse    = 2       | " manually refresh direcory list (avoids display errors)
let g:netrw_hide          = 1       | " show not-hidden files only
let g:netrw_keepdir       = 0
let g:netrw_list_hide     = '^\..*' | " Explore mode: hide files starting with dot
let g:netrw_liststyle     = 3       | " 3=tree
let g:netrw_preview       = 0       | "
let g:netrw_winsize       = 20      | " window size in percent


highlight WordBold cterm=bold gui=bold
let w:m1 = 0
function! HighlightWordUnderCursor()
    if(exists('w:m1') && w:m1 > 0)
      silent! call matchdelete(w:m1)
      let w:m1 = 0
    endif
    let l:currentword = escape(expand('<cword>'), '.')
    if(strlen(l:currentword) > 0)
      let w:m1=100
      silent! call matchadd('WordBold', '\<'.l:currentword.'\>', -1, w:m1)
    endif
endfunction

autocmd! CursorHold,CursorHoldI * call HighlightWordUnderCursor()
if version >= 702 " clean up (see: http://vim.wikia.com/wiki/VimTip396)
  autocmd BufWinLeave * call clearmatches()
endif


" avoids openin an empty buffer when restoring bufferlist from viminfo...
if argc() == 0
    autocmd VimEnter * nested :silent bun
endif
" au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main
" Enable omni completion.
" autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
" autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
" auto complete closing tag name when entering </-[space]
" autocmd Filetype html,markdown,xml iabbrev </ </<C-X><C-O>
" autocmd FileType python setlocal omnifunc=jedi#completions
" following autocommands are there to call neovim functions...
" autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
" autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
" autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
"
" set termguicolors
..