aboutsummaryrefslogtreecommitdiff
path: root/vimrc-full
diff options
context:
space:
mode:
Diffstat (limited to 'vimrc-full')
-rw-r--r--vimrc-full1295
1 files changed, 0 insertions, 1295 deletions
diff --git a/vimrc-full b/vimrc-full
deleted file mode 100644
index 468c505..0000000
--- a/vimrc-full
+++ /dev/null
@@ -1,1295 +0,0 @@
1" vim: noai:ts=2:sw=2:sts=2 iskeyword+=\:,\!,\<,\>,\-,\& number
2
3"=======================================================================================================================
4" GENERAL:
5"=======================================================================================================================
6set exrc | " enable exrc, a specific .exrc per project, which can contain usual .vimrc commands
7set textwidth=0 | " better done with modeline or local exrc and not here
8set ts=4 sts=4 sw=4 expandtab | " better done with a modeline or local exrc
9set virtualedit=all | " virtual edit should be default behaviour, because I don't see any reason against
10set nonumber norelativenumber | " do not show numbers by default, because that causes a performance loss, instead activate them on a file type basis
11set ignorecase smartcase hlsearch | " search with ignore case by default, but use case sensitive search when one capital char is contained and highlight while typing (even though its slower)
12set cindent cinoptions+=(0 | " indent at parentheses
13
14
15set path+=** | " allow recursive searches for files
16let &path = &path.",/usr/lib/modules/".substitute(system('uname -r'), "\n", "", "")."/build/include"
17
18"=======================================================================================================================
19" SHELL
20"=======================================================================================================================
21if filereadable("/bin/bash")
22 set shell=/bin/bash | " many scripts rely on bash, but its path varies why it is commented out here
23elseif filereadable("/usr/local/bin/bash")
24 set shell=/usr/local/bin/bash
25endif
26
27"=======================================================================================================================
28" Persistent undo
29"=======================================================================================================================
30if has('persistent_undo')
31 if isdirectory('/dev/shm')
32 set undodir=/dev/shm/ | " save undo file in memory. That is volatile, but fast and we have GIT for longer lasting undoes
33 set directory=/dev/shm/ | " swap file directory to RAM
34 set swapfile
35 elseif isdirectory('/tmp/')
36 set undodir=/tmp/
37 endif
38 set undofile | " preserve undo history when closing and reopening buffers (see :help undo-persistence)
39endif
40
41"=======================================================================================================================
42" multi byte
43"=======================================================================================================================
44if has("multi_byte")
45 scriptencoding utf-8 | " tell vim that we are using UTF-8 here
46 set encoding=utf-8 | " we need default UTF-8 encoding to use cool chars as line break and so on (see below)
47 let &termencoding=&encoding | " once we use special chars we assume everybody uses a terminal supporting those
48
49 set fillchars= | " initialize empty fillchars
50 set listchars= | " initialize empty listchars
51
52 if &term == "linux"
53 set fillchars+=vert:\│ | " cool vertical split char
54 else
55 set fillchars+=vert:\║ | " cool vertical split char
56 endif
57
58 set fillchars+=fold:\ | "
59 set fillchars+=diff:\ | " a white space gets used here
60
61 set listchars+=extends:» | " symbols used when using :set list (which displays non-printable chars)
62 set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars)
63
64 set listchars+=tab:▏\ | "
65 set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars)
66 " set listchars+=eol:↲ | " symbols used when using :set list (which displays non-printable chars)
67 set listchars+=space:· | " symbols used when using :set list (which displays non-printable chars)
68 set showbreak+=› | " symbol used in the beginning of a wrapped line
69
70 " automatically enter list mode when going in insert mode (makes above syntax command temporarily ineffective)
71 set nolist
72 autocmd InsertEnter * set list
73 autocmd InsertLeave * set nolist
74" set fillchars+=stlnc:\― | "
75end
76
77
78"=======================================================================================================================
79" SPELL_CHECKING
80"=======================================================================================================================
81let g:spellfile_URL='http://ftp.vim.org/vim/runtime/spell'
82" add local user default spell file as primary source for words
83let &spellfile=fnamemodify($MYVIMRC, ":p:h")."/spell/spellfile-user.UTF-8.add"
84
85set nospell | " disable spell checker by default
86set spelllang=en,de | " languages for the spell checker
87set spellsuggest=10 | " how many words will z= suggest?
88set thesaurus+=~/.vim/thesaurus/php.txt
89
90"=======================================================================================================================
91" cscope
92"=======================================================================================================================
93" http://vim.wikia.com/wiki/Cscope
94if has('cscope') " compiled with cscope support?
95 set cscopetag " CTRL-] uses cscope first, then ctags
96 set cscopeverbose
97
98 if has('quickfix')
99 set cscopequickfix=s+,c+,d+,i+,t+,e+
100 endif
101
102 if has('menu')
103 1001menu &Cscope.find.c\ symbol
104 \<tab>s
105 \ :cscope find s <cword><:cR>
106 1001menu &Cscope.find.definition
107 \<tab>g
108 \ :cscope find g <cword><:cR>
109 1001menu &Cscope.find.functions\ called\ by\ this
110 \<tab>d
111 \ :cscope find d <cword><:cR>
112 1001menu &Cscope.find.functions\ calling\ this
113 \<tab>c
114 \ :cscope find c <cword><:cR>
115 1001menu &Cscope.find.text\ string
116 \<tab>t
117 \ :cscope find t <cword><:cR>
118 1001menu &Cscope.find.egrep\ pattern
119 \<tab>e
120 \ :cscope find e <cword><:cR>
121 1001menu &Cscope.find.this\ file
122 \<tab>f
123 \ :cscope find f <cword><:cR>
124 1001menu &Cscope.find.files\ including\ this\ file
125 \<tab>i
126 \ :cscope find i <cword><:cR>
127 1001menu &Cscope.find.places\ where\ this\ symbol\ is\ assigned\ a\ value
128 \<tab>a
129 \ :cscope find a <cword><:cR>
130 1001menu &Cscope.-Sep1-
131 \ :
132 1001menu &Cscope.create\ and\ add\ database
133 \ :cscope kill -1<CR>:execute '!find -type f -regex ".*\.\(c\\|h\\|cpp\\|cxx\\|hh\\|hpp\\|hxx\)$" <bar> cscope -i- -b -q -v'<CR>:cscope add .<CR>
134 1001menu &Cscope.-Sep2-
135 \ :
136 1001menu &Cscope.add\ \.
137 \ :cscope add .<CR>
138 1001menu &Cscope.show
139 \ :cscope show<CR>
140 1001menu &Cscope.reset
141 \ :cscope reset<CR>
142 endif
143endif
144
145" ======================================================================================================================
146" GUI_VERSION
147" ======================================================================================================================
148if has("gui_running")
149 set guicursor=a:block-blinkon100
150 set browsedir=buffer
151 set toolbar+=text
152 set guiheadroom=0
153 set guioptions+=eig
154 set guioptions-=T | " toolbar
155 set guioptions+=c | " use console dialogues instead of popups
156 set guioptions+=a | " auto select: copy&paste using middle click
157 set guioptions+=m | " remove menu
158 set guioptions-=e | " do not display tabs
159 set guioptions-=L | " do not show left scrollbar
160 set guioptions-=r | " do not show right scrollbar
161 set winaltkeys=menu | " behave like other windows: ALT-key can be used to open the menu (and cannot be :remaped)
162" set selectmode=mouse,key,cmd | " enters vim's select mode when pressing shift-left or shift-END
163" set keymodel=startsel,stopsel | " makes shift-left, shift-right available for selecting text
164
165
166 " its possible to define alternative fonts (order matters)
167 set guifont=Monospace\ 10
168 set guifont+=Noto\ Sans\ Mono\ Bold
169 set guifont+=Noto\ Sans\ Mono\ Bold
170 set guifont+=Hasklug\ Nerd\ Font\ Mono\ Semi-Bold\ 10
171 set guifont+=Hasklig\ Semi-Bold\ 10
172 set guifont+=Bitstream\ Vera\ Sans\ Mono\ 10
173 set guifont+=FuraMono\ Nerd\ Font\ Mono\ Medium\ 11
174 set guifont+=Source\ Code\ Pro\ for\ Powerline\ SemiBold\ 10
175 set guifont+=LiterationMono\ Nerd\ Font\ Mono\ 10
176 set guifont+=RobotoMono\ Nerd\ Font\ Medium\ 10
177 set guifont+=Source\ Code\ Pro\ Semi-Bold\ 10
178 set guifont+=Dejavu\ Sans\ Mono\ for\ Powerline\ Semibold
179 set guifont+=Droid\ Sans\ Mono\ for\ Powerline\ 10
180 set guifont+=Meslo\ LG\ M\ for\ Powerline\ 10
181
182 " like in the terminal: use Ctrl-shift-v for paste in vim's command editor
183 cnoremap <c-s-v> <c-r>*
184endif
185
186" ======================================================================================================================
187" SETTINGS:
188" ======================================================================================================================
189set breakindent | " Every wrapped line will continue visually indented
190set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well)
191set concealcursor=nc | " limits the display of concealed text to normal and command mode
192set conceallevel=2 | " replace escaped chars by their UTF-8 representation (useful for LaTeX)
193set confirm | " asks 'do you want to save?'
194set cpoptions+=P | " makes :w filename set the current buffer to filename
195set hidden | " allows switching buffers even if the current buffer contains changes (displays +)
196set linebreak | " wrap long lines at char 'breakat', not inside words
197set mousemodel=popup | " only in gvim: right click opens a pop-up-menu
198set mouse=n | " allow mouse in normal mode only, so one can use the terminals c&p feature in insert mode
199set noautochdir | " When on, Vim will change the current working directory
200set nostartofline | " when scrolling: do not move the cursor to column 1
201set nowrap | " but do not (by default) wrap long lines around
202set nrformats+=alpha | " allows CTRL-A & CTRL-X to increment and decrement letters, not just numbers
203set incsearch | " highlight pattern while entering it (performance wise this isn't that good)
204
205if has('nvim') " Neovim?
206set inccommand=nosplit | " preview substitute and such things in real time
207endif
208
209set pumheight=8 | " Determines the maximum number of items to show in the pop-up menu for
210set scrolljump=5 | " how many lines get scrolled into view when cursor reaches the screens edge
211set scrolloff=0 | " keeps cursor centered
212set shiftround | " indent/un-indent snaps to multiple of shiftwidths
213set writedelay=0
214
215" display and performance
216set lazyredraw | " disables redraw during macro execution (improves performance)
217set cmdheight=2 | " sets the command line's height
218set signcolumn=yes | " auto=auto hide, yes=always, no=never show the column with error indicators
219set nocursorcolumn | " turn visual cursor column off (improves performance)
220set updatetime=80 | " updates the screen more often
221set redrawtime=1500 | " Timeout in milliseconds for redrawing the screen (switches syntax off when ssh too slow) / CTRL+L to retry
222set notimeout | " improves performance but is known to cause problems on slow terminals
223set ttimeout ttimeoutlen=150 | " set Esc key timeout in ms-
224set showcmd | " essential: show keys of combined commands in the lower right corner (BUT SLOW, makes cursor flickering)
225set showtabline=2 | " 0: never, 1: only if there are at least two tabs, 2:always
226set shortmess+=I | " don't give the intro message when starting Vim |:intro|.
227set wildmenu | " use a menu in the command line
228set wildmode=longest:full | " do not preselect any entry and show all possible
229
230" code completion
231" set dictionary=/usr/share/dict/cracklib-small
232" set complete+=k " make default completer <C-N> respect the dictionary
233set complete-=u " scan current and included files
234set complete+=i " scan current and included files
235set complete+=d " scan current and included files for defined name or macro
236set complete+=d | " scan current and included files for defined name or macro
237set complete+=i | " scan current and included files for completions
238set tagcase=match | " tagcase match, because we mostly use ^] to jump around and that variant respects the upper/lower case [followscs, followic, match, ignore]
239set tags+=../tags
240
241" code folding...
242set nofoldenable | " disable folding, because we have zi to toggle foldenable :)
243set foldclose=all | " automatically fold, when the cursor leaves the folded area
244set foldcolumn=1 | " I think I don't need this second indicator
245" set numberwidth=5
246" set foldmethod=syntax | " foldlevel: syntax, indent, manual / foldmethod=syntax makes Vim incredible slow
247set foldnestmax=1 | " top level folding only
248set foldopen=block,hor,search | " when do we unfold?
249" set foldtext=Foldtext() | "
250" set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\v^/[/*]\','','g')
251" set foldtext='⊞\ '.substitute(getline(v:foldstart),'^[\ '.printf(&cms,'').']*','','').'↵'.getline(v:foldstart+1).'↵'.getline(v:foldstart+2)
252" set foldtext=repeat('',indent(v:foldstart)).substitute(substitute(substitute(join(getline(v:foldstart,v:foldend)),'\\s\\s\\+\\\|\[\*\/\]','\ ','g'),'\^\\s\\+','','g'),\ '\\s\\s\\+',\ '\ ',\ 'g')
253set foldtext=printf('%*s%.*S',indent(v:foldstart),'',&textwidth-indent(v:foldstart),substitute(substitute(join(getline(v:foldstart,v:foldend),'\ '),'[[:space:]]\\+','\ ','g'),'^[[:space:]]','','g'))
254
255" works ...
256" set foldexpr=match(synIDattr(synID(v:lnum,indent(v:lnum)+1,0),'name'),'Comment')>-1
257set foldexpr=!empty(filter(synstack(v:lnum,indent(v:lnum)+1),{_,val->match(synIDattr(val,'name'),'Comment')>-1}))
258
259" set foldtext=printf('%*s%.'.eval(&textwidth-indent(v:foldstart)).'S',indent(v:foldstart),'',substitute(substitute(substitute(join(getline(v:foldstart,v:foldend)),'\\s\\s\\+\\\|\[\*\/\]','\ ','g'),'\^\\s\\+','','g'),\ '\\s\\s\\+',\ '\ ',\ 'g'))
260
261" vim window behaviour
262set splitbelow | " open new windows below the current one (i find that more intuitive)
263set splitright | " this also works for me and makes better use of the scren space I think
264set winminwidth=0 | " (and all other windows, so TODO: watch out)
265set winwidth=30 | " keep NERDTreeWindow at least this size
266
267
268" vim session handling and restore behaviour
269set viminfo+=% | " restore buffer list
270set sessionoptions=
271set sessionoptions+=buffers
272set sessionoptions+=curdir
273set sessionoptions+=folds
274set sessionoptions+=resize
275set sessionoptions+=slash
276set sessionoptions+=tabpages
277set sessionoptions+=unix
278set sessionoptions+=winpos
279set sessionoptions+=winsize
280
281
282" set nocindent smartindent | " use smart indent rather then cindent
283set noautoindent
284set nosmartindent
285
286set noshiftround | " indent/un-indent sna=ps to multiple of shiftwidths
287set noequalalways | " do not evenly size windows when opening new or closing old
288set nocursorline | " turn visual cursor line off (improves performance)
289"=======================================================================================================================
290
291" Vim 8 has a terminal command...
292if has('terminal')
293 " use default ESC key to leave insert mode in the internal terminal emulator
294 tnoremap <Esc> <C-W>N
295 " make terminal windows hidden by default (copied from :help terminal)
296 autocmd BufWinEnter * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
297endif
298
299
300" NEOVIM_incompatible:
301"
302if has('nvim') " Neovim?
303 autocmd TermOpen term://* set nobuflisted
304 " use default ESC key to leave insert mode in the internal terminal emulator
305 tnoremap <Esc> <C-\><C-n>
306" set shada+=n~/.vim/shada | " shada file to use
307"
308 menu &UI.&Open\ in\ Serversession
309 \ :execute ':!nvr --servername /tmp/nvimsocket --remote % +'.line('.')<CR>:stopinsert<CR>:set readonly<CR>
310
311else " default Vim?
312 autocmd VimLeave * call system("echo -n $'" . escape(getreg(), "'") . "' | xsel -ib")
313
314 set ttymouse=xterm2
315 set ttyscroll=100 | " improves speed for terminal vim, incompatible with nvim
316 set ttyfast | " improves speed for terminal vim (incompatible with nvim)
317 set nottybuiltin | " use external termcaps
318 set restorescreen | " restores the console after exiting vim (intentionally not in nvim)
319 "
320 let g:loaded_ruby_provider = 1 " disable ruby support
321 let g:loaded_python_provider = 1 " disable python 3
322
323 if version >= 702 " clean up (see: http://vim.wikia.com/wiki/VimTip396)
324 autocmd BufWinLeave * call clearmatches()
325 endif
326
327
328 " scripts from the default vim installation, which do not get loaded by default, but are useful.
329 if filereadable($VIMRUNTIME.'/macros/editexisting.vim')
330 packadd! editexisting
331 endif
332
333 " load default plugin 'matchit' to allow % to jump between tags
334 if filereadable($VIMRUNTIME.'/macros/matchit.vim')
335 packadd! matchit
336 endif
337
338endif
339
340
341if has("autocmd")
342 set modeline | " set variables specific to a file, like indentation by adding a comment
343 " set default completion function in case YouCompleteMe cannot help
344 " set omnifunc=syntaxcomplete#Complete
345
346 augroup set_window_title " {
347 " autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]"
348 autocmd CursorHold * let &titlestring = "%t %y ".$USER."@".hostname().":%{expand(\"%:~:.:h\")}"
349 set title
350 " autocmd CursorHold * let &titlestring = "Vim (".airline#extensions#tagbar#currenttag().")"
351
352 " set window title for screen(3)
353 if &term == "screen"
354 set t_ts=k
355 set t_fs=\
356 endif
357 if &term == "screen" || &term == "xterm"
358 set titlelen=40
359 set title
360 endif
361 augroup END
362
363 augroup ChangeIcon
364 "if filereadable("/usr/bin/xseticon")
365 "if filereadable("~/.vim/nvim.png")
366 " autocmd VimEnter * silent :execute "!xseticon -id $WINDOWID ~/.vim/nvim.png"
367 " autocmd VimLeave * silent :execute "!xseticon -id $WINDOWID /usr/share/icons/gnome/32x32/apps/xfce-terminal.png"
368 "endif
369 "endif
370 augroup END
371
372 " Fix terminal title =================================================================================================
373 " autocmd VimEnter * let &t_EI .= "\<Esc>[0 q"
374 " autocmd VimEnter * let &t_SI = "\<Esc>]12;green\x7"
375 autocmd VimLeave * silent !echo -ne "\033]112\007"
376
377 " highlight word under the cursor ====================================================================================
378 let w:m1 = 0
379 function! HighlightWordUnderCursor()
380 if(exists('w:m1') && w:m1 > 0)
381 silent! call matchdelete(w:m1)
382 let w:m1 = 0
383 endif
384 let l:currentword = escape(expand('<cword>'), '.')
385 if(strlen(l:currentword) > 0)
386 let w:m1=100
387 silent! call matchadd('BoldUnderline', '\<'.l:currentword.'\>', -1, w:m1)
388 endif
389 endfunction
390 autocmd! CursorHold,CursorHoldI * call HighlightWordUnderCursor()
391
392 " hitting K over a keyword shows a help in a buffer.
393 " Here we define the commands used to look those keywords up
394 " as per file type...
395 augroup filetype_specific
396 autocmd FileType python setlocal keywordprg=pydoc
397 autocmd FileType vim setlocal keywordprg=:help |.
398 autocmd FileType c,cpp setlocal equalprg=clang-format
399 autocmd FileType c,cpp setlocal breakat-=-
400
401 if filereadable("/usr/bin/vendor_perl/ack")
402 autocmd FileType c,cpp set grepprg=/usr/bin/vendor_perl/ack\ --type=cc\ --nogroup\ --column\ $*
403 autocmd FileType c,cpp set grepformat=%f:%l:%c:%m
404 endif
405
406 autocmd BufWinEnter * if &previewwindow | setlocal nonumber signcolumn=no filetype=c nobuflisted | endif
407
408
409 " autocmd FileType c,cpp setlocal iskeyword-=_
410
411 " the following helps to make file=/etc/something work with gf, but disallows filenames with an equal sign in them
412 autocmd FileType conf setlocal isfname-==
413
414
415 autocmd Filetype css command! CSSsort :g/{/+1;/}/-1 sort
416
417 " keyboard mapping for xml alike languages
418 " Alt-Up : Move cursor up one tag
419 " Alt-Down: Move cursor down one tag
420 " leader-=: tidies currently selected tag and subtags and sorts attributes by name (alphabetically)
421 autocmd Filetype html,markdown,xml iabbrev </ </<C-X><C-O>
422 autocmd Filetype html,htmldjango,xml
423 \ :nnoremap
424 \ <M-Down>
425 \ :call search('^ *<', 'e')<CR>:nohlsearch<CR>|
426 \ :nnoremap
427 \ <M-Up>
428 \ :call search('^ *<', 'eb')<CR>:nohlsearch<CR>|
429 \ :nnoremap
430 \ <leader>=
431 \ vat:'<,'>!tidy -xml --wrap 0 --sort-attributes alpha 2>/dev/null<CR>vat=
432 augroup END
433
434 " autocmd BufNewFile set nobuflisted
435 " use the shada/viminfo file to return the cursor to where it was...
436 autocmd BufReadPost * call setpos(".", getpos("'\""))
437
438 augroup CurrentFileName
439 " highlight the current files name inside the document...
440 let @g = ":exe ':match SpellBad /'.escape(expand('%:t'), '.').'/'"
441 " put the current files name after the cursor...
442 let @f = ":exe ':normal a'.expand('%:t')"
443
444 " grep all buffers for a given string and return result in a quickfix window
445 let @q = ":cex [] | bufdo vimgrepadd /foo/g % | cw"
446
447 let @l = ":let g:signify_vcs_cmds={'git': 'git diff --no-color --no-ext-diff -U0 HEAD^ -- %f'}|:SignifyRefresh"
448
449 if has('menu')
450 source $VIMRUNTIME/menu.vim
451 set wildmenu
452 set cpo-=<
453 set wcm=<C-Z>
454
455 01menu &Functions.toggle\ file\ browser
456 \<Tab><leader><leader>
457 \ <leader><leader>
458 01menu &Functions.-Sep0- :
459
460 01menu &Functions.help
461 \<Tab><F1>
462 \ <F1>
463 01menu &Functions.bp:\ previous\ buffer
464 \<Tab><F2>
465 \ <F2>
466 01menu &Functions.bn:\ next\ buffer
467 \<Tab><F3>
468 \ <F3>
469 01menu &Functions.^wc\:\ close\ window
470 \<Tab><F4>
471 \ <F4>
472 01menu &Functions.-Sep1- :
473
474 01menu &Functions.make
475 \<Tab><F5>
476 \ <F5>
477 01menu &Functions.clear\ matches,\ update\ viewport
478 \<Tab><F6>
479 \ <F6>
480 01menu &Functions.copen\:\ show\ quickfix\ list
481 \<Tab><F7>
482 \ <F7>
483 01menu &Functions.lopen\:\ show\ location\ list
484 \<Tab><F8>
485 \ <F8>
486 01menu &Functions.-Sep2- :
487
488 01menu &Functions.toggle\ tagbar
489 \<Tab><F9>
490 \ <F9>
491
492 if has("gui_running") == 0
493 " in the gui F10 already triggers the menu, not in a terminal vim, so upgrade that...
494 map <F10> :emenu <C-Z>
495 endif
496 01menu &Functions.activate\ menu\ (:emenu)
497 \<Tab><F10>
498 \ <F10>
499
500 01menu &Functions.undef11
501 \<Tab><F11>
502 \ <F11>
503 01menu &Functions.undef12
504 \<Tab><F12>
505 \ <F12>
506 01menu &Functions.-Sep2- :
507
508
509 09menu &Directory.print\ current\ directory
510 \<Tab>:pwd
511 \ :pwd<CR>
512
513 09menu &Directory.-Sep- :
514
515 09menu &Directory.Change\ to\ GIT\ root
516 \<Tab>:Gcd
517 \ :Gcd<CR>:pwd<CR>
518
519 09menu &Directory.Change\ to\ current\ buffers\ directory\ (global)
520 \<tab>:cd\ %:p:h
521 \ :cd %:h<CR>:pwd<CR>
522
523 09menu &Directory.Change\ to\ current\ buffers\ directory\ (local\ window)<tab>:lcd\ %:p:h
524 \ :lcd %:p:h<CR>:pwd<CR>
525
526 menu &Git.&Display\ uncommited\ files\ in\ location\ list
527 \ :call setloclist(0, map(systemlist("git diff --name-only --pretty=''"), {_, p->{'filename': fnamemodify(p, ':.')}}))<CR>:lopen<CR>
528 menu &Git.&Display\ recently\ changed\ files\ in\ quickfix\ list
529 \ :call setqflist([], 'r', {'title': 'Recently changed in GIT', 'items':map(systemlist("git show --name-only --pretty=''"), {_, p->{'filename': fnamemodify(p, ':.')}}) })<CR>:copen<CR>
530 menu &Git.&Display\ last\ changes
531 \ :let g:signify_vcs_cmds={'git': 'git diff --no-color --no-ext-diff -U0 HEAD^ -- %f'}<CR>:SignifyRefresh<CR>
532 menu &Git.&Display\ unmerged\ files\ in\ location\ list
533 \ :call setloclist(0, map(systemlist("git diff --name-only --diff-filter=U \| uniq"), {_, p->{'filename': fnamemodify(p, ':.')}}))<CR>:lopen<CR>
534 menu &Git.&Display\ significance\ of\ changes
535 \ :!git diff --stat HEAD~1..HEAD
536 menu &Git.&Display\ Changed\ files\ compared\ to\ master
537 \ :!git diff --name-status ..master
538
539 menu &Match.Clear\ All\ Matches
540 \<Tab><F6>
541 \ :call clearmatches()<CR>
542
543 menu &Match.-Sep- :
544
545 menu &Match.&dispensable\ white\ spaces
546 \ :call matchadd("Convention", '\s\+$', 0)<CR>
547
548 menu &Match.&long\ lines\ (exeeding\ textwidth)
549 \ :call matchadd("Convention", '\%>'.&textwidth.'v.', 0)<CR>
550
551 menu &Match.Highlight\ current\ file\ name
552 \ :call matchadd("Search", escape(expand('%:t'), '.'))<CR>
553
554 " :execute ':match SpellBad /'.escape(expand('%:t'), '.').'/'<CR>
555
556 menu &Window.-Sep- :
557
558
559 menu &Window.Scratch
560 \ :Scratch<CR>
561
562
563 menu &Find.file\ under\ the\ cursor
564 \<Tab>gf
565 \ gf
566
567 menu &Find.Open\ search\ results\ in\ location\ list
568 \<Tab>:gf
569 \ :execute ':vimgrep /'.escape(getreg('/'), '.').'/g %'<CR>
570 \ :copen<CR>
571
572 menu &Changes.list
573 \<Tab>:changes
574 \ :changes<CR>
575 menu &Changes.-Sep- :
576 menu &Changes.previous
577 \<Tab>g;
578 \ g;
579 menu &Changes.next
580 \<Tab>g,
581 \ g,
582 menu &List.location.signs\ to\ list
583 \<Tab>CMD
584 \ :execute ":call setloclist(0, map(get(getbufinfo('%')[0], 'signs'), {_, p->extend(p, {'bufnr':buffer_number('.'), 'text':get(p, 'name')})}))"<CR>
585 menu &List.location.list\ to\ signs
586 \<Tab>CMD
587 \ :call execute(extend(['sign define LocationListEntry text=L', 'sign unplace *'], map(getloclist('%'), {key, val->'sign place '.(key+100).' name=LocationListEntry line='.val['lnum'].' buffer='.buffer_number('%')})))<CR>
588 menu &Jump.list
589 \<Tab>:jumps
590 \ :jumps<CR>
591 menu &Jump.-Sep1- :
592 menu &Jump.previous\ position
593 \<Tab>CTRL-O
594 \ <C-O>
595 menu &Jump.next\ position
596 \<Tab>CTRL-I
597 \ <C-I>
598 menu &Jump.-Sep2- :
599 menu &Jump.clear\ list
600 \<Tab>:clearjumps
601 \ :clearjumps
602
603 1000menu &Tag.list
604 \<Tab>:tags
605 \ :tags<CR>
606 1000menu &Tag.selection\ list
607 \<Tab>:ts
608 \ :ts<CR>
609
610 1000menu &Tag.-Sep1- :
611
612 1000menu &Tag.stack.jump\ older
613 \<Tab><C-T>
614 \ :po
615 1000menu &Tag.stack.jump\
616 \<Tab>:ta
617 \ :ta
618 endif
619
620 " autocmd BufEnter * @f
621 augroup END
622
623 " autocmd VimEnter * set nobuflisted
624endif
625
626
627" ======================================================================================================================
628" SHORTCUTS: custom shortcuts
629" inoremap <C-Space> <C-x><C-o>
630" inoremap <C-@> <C-Space>
631
632" Bind CTRL+Backspace to vim's version (CTRL+W) in " <CR> insert mode (only works with gvim)
633inoremap
634 \ <C-Backspace>
635 \ <C-W>
636
637" INDENTATION: allows un-indenting a selected block and keeps selection
638vnoremap < <gv
639vnoremap > >gv
640
641" make shift-home select to the beginning of the line
642nnoremap <s-home> v^
643nnoremap <s-end> v$
644
645nnoremap <s-down> vj
646vnoremap <s-down> j
647nnoremap <s-up> vk
648vnoremap <s-up> k
649
650
651" close current buffer with <leader>q...
652nnoremap <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>.
653" google the word under the cursor
654nnoremap <leader>G :execute ":!xdg-open https://google.de/search?q=".expand("<cword>")
655
656nnoremap <silent> <F5> :make!<CR>
657nnoremap <silent> <F6> :silent syntax sync fromstart<CR>:nohlsearch<CR>:silent match<CR>:silent 2match<CR>:silent 3match<CR>
658nnoremap <leader>r :syntax sync fromstart
659
660nnoremap <silent> <A-Up> :wincmd k<CR>
661nnoremap <silent> <A-Down> :wincmd j<CR>
662nnoremap <silent> <A-Left> :wincmd h<CR>
663nnoremap <silent> <A-Right> :wincmd l<CR>
664
665" INSERT_MODE_MAPPINGS:
666" default copy&paste insert key binding (just in insert mode, so it doesn't conflict
667" with visual block mode)- would have been nice, but collides with c-w for digraphs
668" inoremap <C-V> <C-R>+
669"
670inoremap <C-S> <C-O>:w<CR>
671
672" NEOVIM_SPECIFIC:
673if has('nvim') " only neovim...
674 " shortcut \t opens a terminal in a horizontal split
675 nnoremap <leader>t :new +terminal<CR>
676endif
677
678
679
680" ======================================================================================================================
681" START: LOADING PLUGINS
682" ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
683call plug#begin()
684" Colorschemes:
685Plug 'coderonline/vim-remote-menu'
686" Plug 'bbchung/clighter8'
687" Plug 'octol/vim-cpp-enhanced-highlight'
688" Plug 'vim-scripts/TagHighlight'
689" if ! exists('g:TagHighlightSettings')
690" let g:TagHighlightSettings = {}
691" endif
692" let g:TagHighlightSettings['TagFileName'] = 'tags'
693" let g:TagHighlightSettings['CtagsExecutable'] = 'ctags'
694
695Plug 'chriskempson/base16-vim' | " not just one high quality color scheme (all named base16-*)
696Plug 'NLKNguyen/papercolor-theme' | " the one I like the most
697
698Plug 'mhinz/vim-signify' | " uses the sign column to indicate added, modified and removed lines
699Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin
700Plug 'godlygeek/tabular' | " align code on a sign, like :Tab/=
701Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with '
702let g:signify_vcs_list = [ 'git' ] | " use signify only with git (improves speed when loading buffers, see :h signify)
703let g:signify_cursorhold_insert = 0
704let g:signify_cursorhold_normal = 0
705let g:signify_update_on_bufenter = 0
706let g:signify_update_on_focusgained = 0
707let g:signify_sign_show_count = 1
708
709let g:signify_sign_add = '≫'
710let g:signify_sign_delete = '≪'
711let g:signify_sign_delete_first_line = '≪'
712let g:signify_sign_change = '≶'
713let g:signify_sign_changedelete = g:signify_sign_change
714
715
716" NERDTree: replaces NetRW, as long as it has so many bugs
717Plug 'scrooloose/nerdtree' | "
718let NERDTreeIgnore = ['\.aux$', '\.o$']
719let NERDTreeCascadeSingleChildDir = 0 | " I don't get how one can use <m> to create files in that included directory
720let NERDTreeChDirMode = 0
721let NERDTreeHiddenFirst = 1
722let NERDTreeMinimalUI = 1
723let NERDTreeShowBookmarks = 1 | " show bookmarks by default (when opening for the first time)
724let NERDTreeWinSize = 40
725let NERDTreeQuitOnOpen = 1
726
727" depending on if NERDTree has the focus:
728nnoremap <expr>
729 \ <leader><leader>
730 \ bufwinnr("%")==g:NERDTree.GetWinNum() ? ':NERDTreeClose<CR>' : ':NERDTreeFind<CR>'
731nnoremap <expr>
732 \ <F2>
733 \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':N<CR>'
734
735nnoremap <expr>
736 \ <F3>
737 \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':n<CR>'
738
739nnoremap <F4>
740 \ :wincmd c<CR>
741" close NERDTree if it is the last remaining window (taken from the official documentation)
742" autocmd bufenter *
743" \ if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
744"
745
746
747" map CTRL-PageUp/Down to next/previous buffer
748" and Shift-PageUp/Down to next/previous arglist file
749nnoremap <C-PageUp> :bn<CR>
750nnoremap <C-PageDown> :bp<CR>
751nnoremap <S-PageUp> :N<CR>
752nnoremap <S-PageDown> :n<CR>
753
754
755" Additional: ========================================.
756" Plug 'sheerun/vim-polyglot' " better syntax highlighting/indentation for multiple languages
757" let g:javascript_conceal_function = "ƒ"
758" let g:javascript_conceal_null = "ø"
759" let g:javascript_conceal_this = "@"
760" let g:javascript_conceal_return = "⇚"
761" let g:javascript_conceal_undefined = "¿"
762" let g:javascript_conceal_NaN = "ℕ"
763" let g:javascript_conceal_prototype = "¶"
764" let g:javascript_conceal_static = "•"
765" let g:javascript_conceal_super = "Ω"
766" let g:javascript_conceal_arrow_function = "⇒"
767
768
769" indent within <script> and <style> (default is a zero indent)
770let g:html_indent_script1 = "inc"
771let g:html_indent_style1 = "inc"
772
773Plug 'majutsushi/tagbar' " superseeds taglist-plus, which isn't maintained any more
774let g:tagbar_autoclose = 0
775let g:tagbar_autofocus = 1
776let g:tagbar_autoshowtag = 0
777let g:tagbar_compact = 1
778let g:tagbar_indent = 0
779let g:tagbar_foldlevel = 99
780
781nnoremap <F9> :TagbarToggle<CR>| " bind TagBar to hotkey F9
782
783" Autocompleter: =====================================
784if has("python") || has('python3')
785
786 " ULTISNIPS: code snippet ============================================================================================
787 Plug 'honza/vim-snippets' " dependency of ultisnips (see below)
788 Plug 'SirVer/ultisnips' " replaces loremipsum (and many more)
789 " let g:UltiSnipsExpandTrigger = '<Tab>'| " expands the snippet, be careful not to use <tab> elsewhere (ycm uses it by default, but it has been deactivated by g:ycm_key_list_select_completion)
790 let g:UltiSnipsExpandTrigger = '<Tab>'| " expands the snippet, be careful not to use <tab> elsewhere (ycm uses it by default, but it has been deactivated by g:ycm_key_list_select_completion)
791
792 let g:UltiSnipsJumpForwardTrigger = '<Tab>'|
793 let g:UltiSnipsJumpBackwardTrigger = '<S-Tab>'|
794 "d let g:UltiSnipsJumpForwardTrigger = '<PageDown>'
795 " let g:UltiSnipsJumpBackwardTrigger = '<PageUp>'
796 "let g:UltiSnipsExpandTrigger = '<C-j>'| " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
797 "let g:UltiSnipsJumpForwardTrigger = '<C-j>'| " \
798 "let g:UltiSnipsJumpBackwardTrigger = '<C-k>'| " \
799 "let g:UltiSnipsListSnippets = '<C-`>'| " YouCompleteMe includes those, so this isn't necessary
800 "let g:UltiSnipsListSnippets = '<leader><leader>'| " YouCompleteMe includes those, so this isn't necessary
801 """ Ultisnips
802 " let g:UltiSnipsExpandTrigger="<c-tab>"
803 " let g:UltiSnipsListSnippets="<c-s-tab>"
804
805 if has('nvim')
806 Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
807 " Use deoplete.
808 let g:deoplete#enable_at_startup = 1
809 inoremap <silent><expr> <C-Space> deoplete#mappings#manual_complete()
810
811 Plug 'Shougo/echodoc.vim'
812 let g:echodoc#enable_at_startup = 1
813
814 " Plug 'Rip-Rip/clang_complete'
815 " Plug 'tweekmonster/deoplete-clang2'
816 " Plug 'zchee/deoplete-clang'
817 " let g:deoplete#sources#clang#libclang_path = "/usr/lib/libclang.so"
818 " let g:deoplete#sources#clang#clang_header = "/usr/lib/clang/6.0.0"
819 " let g:deoplete#sources#clang#std#cpp = 'c++1z'
820 " let g:deoplete#sources#clang#clang_complete_database = "/home/max/src"
821 " Plug 'Shougo/neoinclude.vim' " makes vim slow - unfortunatelly
822
823 " Plug 'Shougo/deoplete-clangx' " mentioned in Q&A of deoplete
824 Plug 'autozimu/LanguageClient-neovim', {
825 \ 'branch': 'next',
826 \ 'do': 'bash install.sh',
827 \ }
828
829 let g:LanguageClient_serverCommands = {
830 \ 'cpp': ['clangd']
831 \ }
832 " Plug 'roxma/nvim-completion-manager' unmaintained python version
833 else
834 " YouCompleteMe: =====================================================================================================
835 " Plug 'Valloric/MatchTagAlways' " highlights the closing tag/brace/...
836 Plug 'Valloric/YouCompleteMe', {
837 \ 'do' : 'python install.py --clang-completer --system-libclang --quiet',
838 \ }
839 let g:ycm_error_symbol = '✖' " insert this as an error symbol in the gutter bar/sign column
840 let g:ycm_warning_symbol = '➔' " insert this as a warning symbol in the gutter bar/sign coloumn
841
842 let g:ycm_autoclose_preview_window_after_insertion = 0
843 let g:ycm_auto_trigger = 1
844 let g:ycm_collect_identifiers_from_tags_files = 1 " Let YCM read tags from Ctags file
845 let g:ycm_confirm_extra_conf = 0 " security is overrated ;)
846 let g:ycm_always_populate_location_list = 0 " we can manually run :YcmDiags to do that
847
848 let g:ycm_key_list_previous_completion = ['Up']
849 let g:ycm_key_list_select_completion = ['Down']
850
851 " Plug 'vim-scripts/dbext.vim' " dependency to allow db related completions
852 " let g:ycm_server_python_interpreter = 'python3'
853 " let g:ycm_python_binary_path = '/usr/bin/python3' " the python interpreter of choice (for code checking)
854 " let g:ycm_add_preview_to_completeopt = 1 " reuse existing preview window
855 " let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword
856 " let g:ycm_complete_in_comments = 1 " Completion in comments
857 " let g:ycm_complete_in_strings = 1 " Completion in string
858 " let g:ycm_min_num_of_chars_for_completion = 6 " we normally avoid identifier based completion, it just helps with long words. Use semantic completions with <C-Space> instead (terrible idea, html snippets not working!)
859 " let g:ycm_min_num_identifier_candidate_chars = 4
860 " let g:ycm_max_num_identifier_candidates = 10
861 " let g:ycm_max_num_candidates = 50
862 " let g:ycm_use_ultisnips_completer = 1 " Default 1, just ensure
863 " let g:ycm_key_list_select_completion = ['<Down>']
864 " let g:ycm_key_list_previous_completion = ['<Up>']
865 " let g:ycm_global_ycm_extra_conf = '.ycm_extra_conf.py'
866 " let g:ycm_semantic_triggers = { 'c': [ 're!.' ] }
867 " " let g:ycm_disable_for_files_larger_than_kb = 16384 " we have faaast computers, don't we?
868 " let g:ycm_show_diagnostics_ui = 0
869 " " disable <tab>-key for YCM so that it can be used with ultisnips
870 " let g:ycm_key_list_select_completion=[]
871 " let g:ycm_key_list_previous_completion=[]
872 endif
873
874
875 " SYNTASTIC: =========================================================================================================
876 if has('nvim')
877 Plug 'w0rp/ale'
878 let g:ale_set_highlights = 0
879 highlight! link ALEWarningSign FoldColumn
880 let g:ale_sign_error = ''
881 let g:ale_sign_style_error = ''
882 let g:ale_sign_info = ''
883 let g:ale_sign_warning = ''
884 else
885 Plug 'scrooloose/syntastic'
886 " set statusline+=%#warningmsg#
887 " set statusline+=%{SyntasticStatuslineFlag()}
888 let g:LatexBox_latexmk_preview_continuously = 1
889 let g:LatexBox_viewer = "evince"
890 let g:syntastic_always_populate_loc_list = 1
891 let g:syntastic_auto_loc_list = 0
892 let g:syntastic_check_on_open = 1
893 let g:syntastic_check_on_wq = 0
894 " let g:syntastic_quiet_messages = {"type":"style"}
895 "
896 " E221: multiple spaces before Operator
897 let g:syntastic_python_flake8_args = '--max-complexity=10 --max-line-length=120 --exclude venv --doctests --exit-zero --ignore=E221'
898 " filter ( = do not display) style/formatting errors and warnings
899 let g:syntastic_error_symbol = '✖'
900 let g:syntastic_style_error_symbol = '✗'
901 let g:syntastic_warning_symbol = '➔'
902 let g:syntastic_style_warning_symbol = '≈'
903 endif
904
905 " JEDI: ==============================================================================================================
906 Plug 'davidhalter/jedi-vim' " jedi gets used to display python function signatures
907 let g:jedi#completions_enabled = 0 " we do not need completions, because we have YouCompleteMe
908 let g:jedi#show_call_signatures = 1 " which sadly does not support signatures like jedi
909 let g:jedi#show_call_signatures_delay = 0
910 let g:jedi#auto_vim_configure = 0
911 let g:pymode_rope = 0 " https://github.com/davidhalter/jedi-vim/issues/163
912 " autocmd FileType python jedi.preload_module('os', 'sys', 'math')
913 " let g:pymode_options_max_line_length = 120
914 " let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301'
915
916endif " has("python")
917
918"=======================================================================================================================
919" TESTING: | " plugins which I am currently trying...
920"=======================================================================================================================
921" Plug 'rhysd/vim-clang-format' | unnecessary, because we can just :pyf /usr/share/clang/clang-format.py
922Plug 'kana/vim-operator-user' " dependency, which allows overriding the = operator for indentation
923
924" TODO: check if this is unrequired, when set equalprog is set to that py file
925autocmd FileType c,cpp,objc map <buffer> = :pyf /usr/share/clang/clang-format.py<CR>
926
927" let g:clang_format#detect_style_file = 1
928" autocmd FileType c,cpp,objc map <buffer> = <Plug>(operator-clang-format)
929
930" Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values)
931" Plug 'rkitover/vimpager'
932" found this command instead (use as PAGER):
933" man -P 'nvim -R -u NORC -c":%!col -b" -c":set buftype=nowrite filetype=man" -' ls
934
935command BuffersToArg :exec ':args '.join(map(range(0, bufnr('$')), 'fnameescape(fnamemodify(bufname(v:val), ":."))'))
936command BufToArg :argadd %:.
937command Gbranch call setqflist([], 'r', {'title':'Git branch selector','items':map(systemlist("git branch"), {_, p->{'filename':'branch','module': fnamemodify(p, ':.')}})})
938
939" the following command opens a preview-window and shows the declaration of
940" the function under the cursor. It also highlights the word to make it easier
941" to spot within a great file
942command Helpme au! CursorHold * nested let @/=expand('<cword>')|exe "silent! psearch ".expand("<cword>")
943
944"=======================================================================================================================
945call plug#end() | " all plugins are getting loaded on this line, don't remove!
946
947" ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
948" END: LOADING PLUGINS
949" ======================================================================================================================
950
951" Deprecated with this configuration, but still useful when deactivating some Plugins
952" NETRW: obsolete with NERDTree
953let g:netrw_alto = 0 | " open files on the right
954let g:netrw_altv = 1 | " open files on the right
955let g:netrw_banner = 0 | " display help messages?
956let g:netrw_browse_split = 4 | " 4=open in previous window
957let g:netrw_fastbrowse = 2 | " manually refresh direcory list (avoids display errors)
958let g:netrw_hide = 1 | " show not-hidden files only
959let g:netrw_keepdir = 0
960let g:netrw_list_hide = '^\..*' | " Explore mode: hide files starting with dot
961let g:netrw_liststyle = 3 | " 3=tree
962let g:netrw_preview = 0 | "
963let g:netrw_winsize = 20 | " window size in percent
964
965" ======================================================================================================================
966" COLORSCHEME:
967" ======================================================================================================================
968
969function! ExtendColorTheme()
970 " let g:status_fg=synIDattr(hlID('Cursor'), 'fg#')
971 " let g:status_bg=synIDattr(hlID('Cursor'), 'bg#')
972 " let g:status_sel=synIDattr(hlID('Text'), 'fg#')
973 " let g:status_sel='#ffffff'
974 let g:status_fg='#00aa00'
975 let g:status_bg='#000000'
976 let g:status_sel='#ffff00'
977
978 " execute 'highlight! StatusLine'
979 " \ .' guibg=NONE'
980 " \ .' guifg='.g:status_bg
981 " \ .' gui=inverse'
982
983 " " execute 'highlight! User1 gui=NONE'
984 " execute 'highlight! User1 guibg='.g:status_sel
985 " execute 'highlight! User1 guifg='.g:status_fg
986
987 " execute 'highlight! User2 gui=NONE'
988 " execute 'highlight! User2 guibg='.g:status_sel
989 " execute 'highlight! User2 guifg=NONE'
990
991
992 filetype on
993 filetype plugin on
994 filetype indent on
995
996 syntax on | " enable syntax highlighting
997 syntax sync minlines=60 | " how many preceding lines will be parsed? (has performance impact)
998
999 " use the default terminal background color as background (allows transparency)
1000 " highlight! Normal guibg=NONE ctermbg=NONE
1001 " highlight! NonText guibg=NONE guifg=black ctermbg=NONE ctermfg=black
1002
1003 " make the ~ (tilde) indicator invisible, which usually marks the EOF
1004 highlight! link EndOfBuffer Ignore
1005
1006 highlight! CursorLineNr cterm=inverse | " ctermbg=black ctermfg=NONE
1007 highlight! Pmenu ctermbg=LightYellow ctermfg=DarkGrey
1008 highlight! PmenuSel ctermbg=blue ctermfg=LightYellow cterm=bold
1009
1010 highlight! link PmenuSbar Pmenu
1011 highlight! PmenuThumb cterm=inverse
1012 highlight! MoreMsg cterm=inverse
1013
1014 highlight! link LineNr Comment
1015 highlight! link Folded Comment
1016 highlight! link SignColumn Comment
1017 highlight! link FoldColumn Comment
1018 " highlight! Folded ctermbg=NONE
1019 " highlight! Cursor guibg=#729fcf ctermbg=yellow
1020 highlight! link VertSplit NonText
1021 " highlight! SpellBad ctermbg=none
1022 highlight! SpecialKey ctermfg=19
1023 highlight! WhiteSpace ctermfg=19
1024
1025 " highlight! link TabLine LineNr
1026 " highlight! TabLineSel ctermbg=blue ctermfg=black
1027 " highlight! link TabLineFill LineNr
1028 highlight! Search ctermbg=LightYellow ctermfg=12 guibg=#fefd86 guifg=#222222
1029 highlight! link WildMenu Search
1030
1031 " generic, which should exist but don't
1032 highlight! SignifySignAdd ctermbg=NONE
1033 highlight! Bold cterm=bold gui=bold
1034 highlight! Italic cterm=italic gui=italic
1035 highlight! Underline cterm=underline gui=underline
1036 highlight! BoldUnderline cterm=bold,underline gui=bold,underline
1037 highlight! BoldItalic cterm=Bold,Italic gui=Bold,Italic
1038
1039 " make tab stop (see listchars) less disturbing...
1040 highlight! link SpecialKey NonText
1041
1042 " highlight! link LightlineMiddle_tabline ColorColumn
1043 " highlight! link LightlineLeft_tabline_1 ColorColumn
1044 " highlight! link LightlineLeft_tabline_0_1 ColorColumn
1045
1046 highlight! Todo guibg=#ffffaa guifg=#000000 gui=bold term=bold
1047 highlight! cStatement guifg=red gui=bold term=bold
1048
1049 highlight! link Convention Error
1050
1051
1052 highlight! link SignifySignAdd LineNr
1053 highlight! link SignifySignChange LineNr
1054 highlight! link SignifySignDelete LineNr
1055 highlight! link SignifySignChangeDelete LineNr
1056 highlight! link SignifySignDeleteFirstLine LineNr
1057
1058 highlight! SpellBad ctermbg=NONE ctermfg=red cterm=NONE
1059 highlight! link YcmErrorSign SpellBad
1060 highlight! link YcmWarningSign Spellbad
1061
1062 " autocmd InsertLeave * call matchadd('Conceal', ' \+$', -1, 101, { 'conceal': '⟶' })
1063 autocmd InsertEnter * silent! call matchdelete(101)
1064 autocmd InsertLeave * silent! call matchadd('Convention', ' \+$', -1, 101, { 'conceal': '⟶' })
1065
1066 " Show trailing whitepace and spaces before a tab as part of the syntax highlighting
1067 " autocmd BufEnter,InsertLeave * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL
1068 " autocmd Syntax * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL
1069 " autocmd BufEnter,BufWritePost * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL
1070 " autocmd InsertEnter * syntax clear Convention
1071 " autocmd BufEnter,InsertLeave * execute ':syntax match Convention /\%>'.&textwidth.'v./ containedin=ALL'
1072
1073 autocmd InsertEnter * set colorcolumn=80,120
1074 autocmd InsertLeave * set colorcolumn&
1075 " set colorcolumn= | " not used, because we have a :match directive for textwidth
1076 "
1077" if argc() == 0
1078 " rv
1079 " autocmd VimEnter * split +bro\ ol
1080 " endif
1081endfunction
1082autocmd! ColorScheme * call ExtendColorTheme()
1083
1084
1085
1086" ======================================================================================================================
1087" CONVENIENCE:
1088" ======================================================================================================================
1089command Vimls
1090 \ call setloclist(0, map(getbufinfo({'buflisted':1}),
1091 \ "{'bufnr': v:val.bufnr,
1092 \ 'lnum': v:val.lnum,
1093 \ 'text': '='.printf('%*s, % 3d: %s [%s]', winwidth(0) / 2, '', v:val.bufnr, v:val.name, getbufvar(v:val.bufnr, '&buftype')),
1094 \ 'pattern': 'not loaded'}
1095 \ "))
1096
1097command Ctoggle
1098 \ if(get(getqflist({'winid':1}), 'winid') == win_getid())|cclose|else|botright copen|endif
1099command Ltoggle
1100 \ if(get(getloclist(0, {'winid':1}), 'winid') == win_getid())|lclose|else|lopen|endif
1101
1102
1103
1104" nnoremap <silent> <ESC> :lclose<CR> " brings vim into REPLACE mode (R)
1105nnoremap <silent> <F7> :Ltoggle<CR>
1106nnoremap <silent> <F8> :Ctoggle<CR>
1107nnoremap <silent> <F12> :Vimls<CR>:Ltoggle<CR>
1108
1109" exec current line as a command, insert output of command (from: https://youtu.be/MquaityA1SM?t=35m45s)
1110nnoremap Q !!$SHELL<CR>
1111
1112
1113" ======================================================================================================================
1114" TESTING:
1115" ======================================================================================================================
1116" avoids openin an empty buffer when restoring bufferlist from viminfo...
1117" if argc() == 0
1118" silent autocmd VimEnter * nested :silent bun
1119" endif
1120
1121autocmd TextYankPost * echo '> text yanked to '.(
1122 \ get(v:event,'regname') == ''
1123 \ ? 'default register'
1124 \ : 'register '.get(v:event,'regname'))
1125
1126autocmd VimEnter,WinEnter * exec ':set scrolljump='.winheight(0)/2
1127
1128" display highlight group under the cursor
1129map <leader>h :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<CR>
1130
1131if filereadable(expand("~/.vimrc_background")) && filereadable(expand("~/.config/base16-shell/colortest"))
1132 let g:base16_shell_path="~/.config/base16-shell/scripts"
1133 let base16colorspace=256
1134 " let syntax_cmd="skip" " vim internal, use base16 and no default colors
1135 set background=dark
1136 source ~/.vimrc_background
1137else
1138 let g:PaperColor_Theme_Options = {
1139 \ 'theme': {
1140 \ 'default': {
1141 \ 'transparent_background': 0
1142 \ }
1143 \ }
1144 \ }
1145 set background=light
1146 colorscheme PaperColor
1147endif
1148
1149
1150augroup status
1151 set noshowmode | " mode will be shown twice, in lightline and below, so we want to deactivate one
1152 set laststatus=2 | " required by AirLine and Lightline, without status line does not appear until a window split
1153
1154 let g:status_sym_start = ''
1155 let g:status_sym_end = ''
1156 let g:status_sym_sep_start = ''
1157 let g:status_sym_sep_end = ''
1158 let g:symbol_branch = ''
1159
1160 if &term == "linux"
1161 let g:symbol_branch = ''
1162
1163 let g:group_active = "StatusLineTerm"
1164 let g:group_inactive = "StatusLineTermNC"
1165 let g:group_tabline = "StatusLineTerm"
1166 else
1167 let g:group_active = "StatusLine"
1168 let g:group_inactive = "StatusLineNC"
1169 let g:group_tabline = "TabLine"
1170 endif
1171
1172 " this function reverts foreground color and background color of a given
1173 " highlight group and returns the name of a newly created _invert group
1174 function! CreateInvertGroup(highlight_group)
1175 if(synIDattr(hlID(a:highlight_group), "reverse")==1)
1176 let w:color=synIDattr(hlID(a:highlight_group), "fg#")
1177 else
1178 let w:color=synIDattr(hlID(a:highlight_group), "bg#")
1179 endif
1180
1181 let l:retval=a:highlight_group.'_invert'
1182 if(exists('w:color') && w:color == '')
1183 let w:color = 'NONE'
1184 endif
1185 silent! exec 'highlight '.retval.' gui=NONE guifg='.w:color.' cterm=NONE ctermfg='.w:color
1186 return l:retval
1187 endfunction
1188
1189 function! UpdateStatus(highlight_group)
1190 let l:invert_group = CreateInvertGroup(a:highlight_group)
1191 let l:mode = get({
1192 \ 'n' : 'normal',
1193 \ 'i' : 'insert',
1194 \ 'R' : 'replace',
1195 \ 'v' : 'visual',
1196 \ "V" : 'visual line',
1197 \ "\<C-V>" : 'visual block',
1198 \ 'c' : 'command',
1199 \ 's' : 'select',
1200 \ 'S' : 'select line',
1201 \ "\<C-s>" : 'select block',
1202 \ 't' : 'terminal'
1203 \ }, mode(), mode())
1204 return ''
1205 \ ."%#StatusLineHighlight#"
1206 \ ."%#".a:highlight_group."#"
1207 \ ."%(%w%h%q%)".' '.l:mode.' '
1208 \ .g:status_sym_sep_start.' '
1209 \ ."%{(argc()>0\ ?\ argidx()+1.':'.argc().' '.g:status_sym_sep_start.' '\ :\ '')}"
1210 \ ."%{winbufnr(0).' '.g:status_sym_sep_start}"
1211 \ ."%{(&readonly\ ?\ '\ \ \ '\ :\ '')}"
1212 \ ."%{(&modified\ ?\ '\ \ '.nr2char(0xF0C7).'\ '\ :\ '')\ }"
1213 \ ."%{(haslocaldir() ?\ ' '.fnamemodify(getcwd(),\ ':.').' '.nr2char(0xe0b1)\ \:\ '')}\ "
1214 \ ."%{(&buftype\ ==\ \"terminal\"\ ?\ has('nvim')?b:term_title:expand(&titlestring)\ :\ substitute(expand('%:p'),\ '^'.getcwd(-1).'/*',\ '',\ ''))\ }"
1215 \ ."%1(%)"
1216 \ ."%#".l:invert_group."#"
1217 \ .g:status_sym_end
1218 \ .''
1219 \ ."%="
1220 \ .''
1221 \ ."%#".l:invert_group."#"
1222 \ .g:status_sym_start
1223 \ ."%#".a:highlight_group."#"
1224 \ ."%1(%)"
1225 \ ."%{(&filetype\ !=\ ''\ ?\ &filetype\ :\ &buftype)}"
1226 \ ."%(\ %{g:status_sym_sep_end}\ %)"
1227 \ ."%{(&spell\ ?\ &spelllang.' '.g:status_sym_sep_end\ :\ '')}"
1228 \ ."%{(&fileencoding\ !=\ ''\ ?\ &fileencoding.' '.g:status_sym_sep_end.' '\ :\ '')}"
1229 \ ."%{(&fileformat\ !=\ ''\ ?\ ' '.&fileformat.' '\ :\ '')}"
1230 \ .g:status_sym_sep_end.' '
1231 \ ."%4l:%-3c"
1232 \ .g:status_sym_sep_end.' '
1233 \ ."%-3p%%"
1234 endfunction
1235
1236 function! UpdateTabline(highlight_group)
1237 let l:invert_group = CreateInvertGroup(a:highlight_group)
1238 return ''
1239 \ ."%#".a:highlight_group."#"
1240 \ ."%3( \ %)"
1241 \ ."%{getcwd(-1)}"
1242 \ .g:status_sym_sep_start.' '
1243 \ ."%(\ ".g:symbol_branch."\ %{fugitive#head()}\ %)"
1244 \ ."%#".l:invert_group."#"
1245 \ .g:status_sym_end
1246 \ .''
1247 \ ."%="
1248 \ .''
1249 \ ."%#".l:invert_group."#"
1250 \ .g:status_sym_start
1251 \ ."%#".a:highlight_group."#"
1252 \ ."%3(\ %)"
1253 \ ."%(%{v:servername}\ %{v:this_session}%)"
1254 \ .g:status_sym_sep_end.' '
1255 \ ."%(\ \ %{tabpagenr()}/%{tabpagenr('$')}\ %)"
1256 \ ."%##"
1257 \ ."" " end
1258 endfunction
1259
1260 function! ApplyColorScheme()
1261 " set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incompatible with nvim
1262 " set t_ut=
1263 " set up statusline, global and current window individually
1264 set statusline=%!UpdateStatus(g:group_inactive)
1265 setlocal statusline=%!UpdateStatus(g:group_active)
1266 " set up the tabline (match colors)
1267 set tabline=%!UpdateTabline(g:group_tabline)
1268 endfunction
1269 " apply colors from the loaded colorscheme...
1270 " when changing the colorscheme also apply new colors to the statusbar...
1271 autocmd VimEnter,ColorScheme * call ApplyColorScheme()
1272
1273 autocmd WinEnter * setlocal statusline=%!UpdateStatus(g:group_active)
1274 autocmd WinLeave * setlocal statusline<
1275augroup END " status
1276
1277" moved after VimEnter of statusline, so that it does not get overwritten any
1278" more
1279if empty(argv())
1280
1281 " autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val}))
1282
1283 " from the list of recent files: make absolute paths, filter out files not
1284 " contained in cwd and finally filter out directories and non-files...
1285 autocmd StdinReadPre * let s:std_in=1
1286 autocmd VimEnter * if !exists("s:std_in") | call setloclist(0, [], 'r',
1287 \ {
1288 \ 'title':'Recently used files in directory: '.getcwd(),
1289 \ 'items':map(filter(filter(
1290 \ map(copy(v:oldfiles),
1291 \ {_, p->expand(p)}), 'v:val =~ "'.getcwd().'/"'), 'filereadable(v:val)'),
1292 \ {_, p->{'filename': fnamemodify(p, ':.')}})
1293 \ }) | lopen | only | setfiletype qf
1294endif
1295
..