aboutsummaryrefslogtreecommitdiff
path: root/vimrc-full
diff options
context:
space:
mode:
Diffstat (limited to 'vimrc-full')
-rw-r--r--vimrc-full1255
1 files changed, 0 insertions, 1255 deletions
diff --git a/vimrc-full b/vimrc-full
deleted file mode 100644
index 7512908..0000000
--- a/vimrc-full
+++ /dev/null
@@ -1,1255 +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 completeopt+=noinsert | " Do not insert any text for a match until the user selects one
239set completeopt+=noselect | " Do not select a completion from the menu, let the user do that
240set tagcase=match | " tagcase match, because we mostly use ^] to jump around and that variant respects the upper/lower case [followscs, followic, match, ignore]
241set tags+=../tags
242
243" code folding...
244set nofoldenable | " disable folding, because we have zi to toggle foldenable :)
245set foldclose=all | " automatically fold, when the cursor leaves the folded area
246set foldcolumn=2 | " I think I don't need this second indicator
247" set numberwidth=5
248" set foldmethod=syntax | " foldlevel: syntax, indent, manual / foldmethod=syntax makes Vim incredible slow
249set foldnestmax=1 | " top level folding only
250set foldopen=block,hor,search | " when do we unfold?
251" set foldtext=Foldtext() | "
252" set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\v^/[/*]\','','g')
253" set foldtext='⊞\ '.substitute(getline(v:foldstart),'^[\ '.printf(&cms,'').']*','','').'↵'.getline(v:foldstart+1).'↵'.getline(v:foldstart+2)
254" set foldtext=repeat('',indent(v:foldstart)).substitute(substitute(substitute(join(getline(v:foldstart,v:foldend)),'\\s\\s\\+\\\|\[\*\/\]','\ ','g'),'\^\\s\\+','','g'),\ '\\s\\s\\+',\ '\ ',\ 'g')
255set foldtext=printf('%*s%.*S',indent(v:foldstart),'',&textwidth-indent(v:foldstart),substitute(substitute(join(getline(v:foldstart,v:foldend),'\ '),'[[:space:]]\\+','\ ','g'),'^[[:space:]*]','','g'))
256
257" works ...
258" set foldexpr=match(synIDattr(synID(v:lnum,indent(v:lnum)+1,0),'name'),'Comment')>-1
259set foldexpr=!empty(filter(synstack(v:lnum,indent(v:lnum)+1),{_,val->match(synIDattr(val,'name'),'Comment')>-1}))
260
261" 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'))
262
263" vim window behaviour
264set splitbelow | " open new windows below the current one (i find that more intuitive)
265set splitright | " this also works for me and makes better use of the scren space I think
266set winminwidth=0 | " (and all other windows, so TODO: watch out)
267set winwidth=30 | " keep NERDTreeWindow at least this size
268
269
270" vim session handling and restore behaviour
271set viminfo+=% | " restore buffer list
272set sessionoptions=
273set sessionoptions+=buffers
274set sessionoptions+=curdir
275set sessionoptions+=folds
276set sessionoptions+=resize
277set sessionoptions+=slash
278set sessionoptions+=tabpages
279set sessionoptions+=unix
280set sessionoptions+=winpos
281set sessionoptions+=winsize
282
283
284" set nocindent smartindent | " use smart indent rather then cindent
285set noautoindent
286set nosmartindent
287
288set noshiftround | " indent/un-indent sna=ps to multiple of shiftwidths
289set noequalalways | " do not evenly size windows when opening new or closing old
290set nocursorline | " turn visual cursor line off (improves performance)
291"=======================================================================================================================
292
293" Vim 8 has a terminal command...
294if has('terminal')
295 " use default ESC key to leave insert mode in the internal terminal emulator
296 tnoremap <Esc> <C-W>N
297 " make terminal windows hidden by default (copied from :help terminal)
298 autocmd BufWinEnter * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
299endif
300
301
302" NEOVIM_incompatible:
303"
304if has('nvim') " Neovim?
305 autocmd TermOpen term://* set nobuflisted
306 " use default ESC key to leave insert mode in the internal terminal emulator
307 tnoremap <Esc> <C-\><C-n>
308" set shada+=n~/.vim/shada | " shada file to use
309"
310 menu &UI.&Open\ in\ Serversession
311 \ :execute ':!nvr --servername /tmp/nvimsocket --remote % +'.line('.')<CR>:stopinsert<CR>:set readonly<CR>
312
313else " default Vim?
314 autocmd VimLeave * call system("echo -n $'" . escape(getreg(), "'") . "' | xsel -ib")
315
316 set ttymouse=xterm2
317 set ttyscroll=100 | " improves speed for terminal vim, incompatible with nvim
318 set ttyfast | " improves speed for terminal vim (incompatible with nvim)
319 set nottybuiltin | " use external termcaps
320 set restorescreen | " restores the console after exiting vim (intentionally not in nvim)
321 "
322 let g:loaded_ruby_provider = 1 " disable ruby support
323 let g:loaded_python_provider = 1 " disable python 3
324
325 if version >= 702 " clean up (see: http://vim.wikia.com/wiki/VimTip396)
326 autocmd BufWinLeave * call clearmatches()
327 endif
328
329
330 " scripts from the default vim installation, which do not get loaded by default, but are useful.
331 if filereadable($VIMRUNTIME.'/macros/editexisting.vim')
332 packadd! editexisting
333 endif
334
335 " load default plugin 'matchit' to allow % to jump between tags
336 if filereadable($VIMRUNTIME.'/macros/matchit.vim')
337 packadd! matchit
338 endif
339
340endif
341
342
343if has("autocmd")
344 set modeline | " set variables specific to a file, like indentation by adding a comment
345 " set default completion function in case YouCompleteMe cannot help
346 " set omnifunc=syntaxcomplete#Complete
347
348 augroup set_window_title " {
349 " autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]"
350 autocmd CursorHold * let &titlestring = "%t %y ".$USER."@".hostname().":%{expand(\"%:~:.:h\")}"
351 set title
352 " autocmd CursorHold * let &titlestring = "Vim (".airline#extensions#tagbar#currenttag().")"
353
354 " set window title for screen(3)
355 if &term == "screen"
356 set t_ts=k
357 set t_fs=\
358 endif
359 if &term == "screen" || &term == "xterm"
360 set titlelen=40
361 set title
362 endif
363 augroup END
364
365 augroup ChangeIcon
366 "if filereadable("/usr/bin/xseticon")
367 "if filereadable("~/.vim/nvim.png")
368 " autocmd VimEnter * silent :execute "!xseticon -id $WINDOWID ~/.vim/nvim.png"
369 " autocmd VimLeave * silent :execute "!xseticon -id $WINDOWID /usr/share/icons/gnome/32x32/apps/xfce-terminal.png"
370 "endif
371 "endif
372 augroup END
373
374 " Fix terminal title =================================================================================================
375 " autocmd VimEnter * let &t_EI .= "\<Esc>[0 q"
376 " autocmd VimEnter * let &t_SI = "\<Esc>]12;green\x7"
377 autocmd VimLeave * silent !echo -ne "\033]112\007"
378
379 " highlight word under the cursor ====================================================================================
380 let w:m1 = 0
381 function! HighlightWordUnderCursor()
382 if(exists('w:m1') && w:m1 > 0)
383 silent! call matchdelete(w:m1)
384 let w:m1 = 0
385 endif
386 let l:currentword = escape(expand('<cword>'), '.')
387 if(strlen(l:currentword) > 0)
388 let w:m1=100
389 silent! call matchadd('BoldUnderline', '\<'.l:currentword.'\>', -1, w:m1)
390 endif
391 endfunction
392 autocmd! CursorHold,CursorHoldI * call HighlightWordUnderCursor()
393
394 " hitting K over a keyword shows a help in a buffer.
395 " Here we define the commands used to look those keywords up
396 " as per file type...
397 augroup filetype_specific
398 autocmd FileType python setlocal keywordprg=pydoc
399 autocmd FileType vim setlocal keywordprg=:help |.
400 autocmd FileType c,cpp setlocal equalprg=clang-format
401 autocmd FileType c,cpp setlocal breakat-=-
402
403 if filereadable("/usr/bin/vendor_perl/ack")
404 autocmd FileType c,cpp set grepprg=/usr/bin/vendor_perl/ack\ --type=cc\ --nogroup\ --column\ $*
405 autocmd FileType c,cpp set grepformat=%f:%l:%c:%m
406 endif
407
408 autocmd BufWinEnter * if &previewwindow | setlocal nonumber nolist signcolumn=no filetype=c nobuflisted | endif
409
410
411 " autocmd FileType c,cpp setlocal iskeyword-=_
412
413 " the following helps to make file=/etc/something work with gf, but disallows filenames with an equal sign in them
414 autocmd FileType conf setlocal isfname-==
415
416
417 autocmd Filetype css command! CSSsort :g/{/+1;/}/-1 sort
418
419 " keyboard mapping for xml alike languages
420 " Alt-Up : Move cursor up one tag
421 " Alt-Down: Move cursor down one tag
422 " leader-=: tidies currently selected tag and subtags and sorts attributes by name (alphabetically)
423 autocmd Filetype html,markdown,xml iabbrev </ </<C-X><C-O>
424 autocmd Filetype html,htmldjango,xml
425 \ :nnoremap
426 \ <M-Down>
427 \ :call search('^ *<', 'e')<CR>:nohlsearch<CR>|
428 \ :nnoremap
429 \ <M-Up>
430 \ :call search('^ *<', 'eb')<CR>:nohlsearch<CR>|
431 \ :nnoremap
432 \ <leader>=
433 \ vat:'<,'>!tidy -xml --wrap 0 --sort-attributes alpha 2>/dev/null<CR>vat=
434 augroup END
435
436 " autocmd BufNewFile set nobuflisted
437 " use the shada/viminfo file to return the cursor to where it was...
438 autocmd BufReadPost * call setpos(".", getpos("'\""))
439
440 augroup CurrentFileName
441 " highlight the current files name inside the document...
442 let @g = ":exe ':match SpellBad /'.escape(expand('%:t'), '.').'/'"
443 " put the current files name after the cursor...
444 let @f = ":exe ':normal a'.expand('%:t')"
445
446 " grep all buffers for a given string and return result in a quickfix window
447 let @q = ":cex [] | bufdo vimgrepadd /foo/g % | cw"
448
449 let @l = ":let g:signify_vcs_cmds={'git': 'git diff --no-color --no-ext-diff -U0 HEAD^ -- %f'}|:SignifyRefresh"
450
451 if has('menu')
452 source $VIMRUNTIME/menu.vim
453 set wildmenu
454 set cpo-=<
455 set wcm=<C-Z>
456
457 01menu &Functions.toggle\ file\ browser
458 \<Tab><leader><leader>
459 \ <leader><leader>
460 01menu &Functions.-Sep0- :
461
462 01menu &Functions.help
463 \<Tab><F1>
464 \ <F1>
465 01menu &Functions.bp:\ previous\ buffer
466 \<Tab><F2>
467 \ <F2>
468 01menu &Functions.bn:\ next\ buffer
469 \<Tab><F3>
470 \ <F3>
471 01menu &Functions.^wc\:\ close\ window
472 \<Tab><F4>
473 \ <F4>
474 01menu &Functions.-Sep1- :
475
476 01menu &Functions.make
477 \<Tab><F5>
478 \ <F5>
479 01menu &Functions.clear\ matches,\ update\ viewport
480 \<Tab><F6>
481 \ <F6>
482 01menu &Functions.copen\:\ show\ quickfix\ list
483 \<Tab><F7>
484 \ <F7>
485 01menu &Functions.lopen\:\ show\ location\ list
486 \<Tab><F8>
487 \ <F8>
488 01menu &Functions.-Sep2- :
489
490 01menu &Functions.toggle\ tagbar
491 \<Tab><F9>
492 \ <F9>
493
494 if has("gui_running") == 0
495 " in the gui F10 already triggers the menu, not in a terminal vim, so upgrade that...
496 map <F10> :emenu <C-Z>
497 endif
498 01menu &Functions.activate\ menu\ (:emenu)
499 \<Tab><F10>
500 \ <F10>
501
502 01menu &Functions.undef11
503 \<Tab><F11>
504 \ <F11>
505 01menu &Functions.undef12
506 \<Tab><F12>
507 \ <F12>
508 01menu &Functions.-Sep2- :
509
510
511 09menu &Directory.print\ current\ directory
512 \<Tab>:pwd
513 \ :pwd<CR>
514
515 09menu &Directory.-Sep- :
516
517 09menu &Directory.Change\ to\ GIT\ root
518 \<Tab>:Gcd
519 \ :Gcd<CR>:pwd<CR>
520
521 09menu &Directory.Change\ to\ current\ buffers\ directory\ (global)
522 \<tab>:cd\ %:p:h
523 \ :cd %:h<CR>:pwd<CR>
524
525 09menu &Directory.Change\ to\ current\ buffers\ directory\ (local\ window)<tab>:lcd\ %:p:h
526 \ :lcd %:p:h<CR>:pwd<CR>
527
528 menu &Git.&Display\ uncommited\ files\ in\ location\ list
529 \ :call setloclist(0, map(systemlist("git diff --name-only --pretty=''"), {_, p->{'filename': fnamemodify(p, ':.')}}))<CR>:lopen<CR>
530 menu &Git.&Display\ recently\ changed\ files\ in\ quickfix\ list
531 \ :call setqflist([], 'r', {'title': 'Recently changed in GIT', 'items':map(systemlist("git show --name-only --pretty=''"), {_, p->{'filename': fnamemodify(p, ':.')}}) })<CR>:copen<CR>
532 menu &Git.&Display\ last\ changes
533 \ :let g:signify_vcs_cmds={'git': 'git diff --no-color --no-ext-diff -U0 HEAD^ -- %f'}<CR>:SignifyRefresh<CR>
534 menu &Git.&Display\ unmerged\ files\ in\ location\ list
535 \ :call setloclist(0, map(systemlist("git diff --name-only --diff-filter=U \| uniq"), {_, p->{'filename': fnamemodify(p, ':.')}}))<CR>:lopen<CR>
536 menu &Git.&Display\ significance\ of\ changes
537 \ :!git diff --stat HEAD~1..HEAD
538 menu &Git.&Display\ Changed\ files\ compared\ to\ master
539 \ :!git diff --name-status ..master
540
541 menu &Match.Clear\ All\ Matches
542 \<Tab><F6>
543 \ :call clearmatches()<CR>
544
545 menu &Match.-Sep- :
546
547 menu &Match.&dispensable\ white\ spaces
548 \ :call matchadd("Convention", '\s\+$', 0)<CR>
549
550 menu &Match.&long\ lines\ (exeeding\ textwidth)
551 \ :call matchadd("Convention", '\%>'.&textwidth.'v.', 0)<CR>
552
553 menu &Match.Highlight\ current\ file\ name
554 \ :call matchadd("Search", escape(expand('%:t'), '.'))<CR>
555
556 " :execute ':match SpellBad /'.escape(expand('%:t'), '.').'/'<CR>
557
558 menu &Window.-Sep- :
559
560
561 menu &Window.Scratch
562 \ :Scratch<CR>
563
564
565 menu &Find.file\ under\ the\ cursor
566 \<Tab>gf
567 \ gf
568
569 menu &Find.Open\ search\ results\ in\ location\ list
570 \<Tab>:gf
571 \ :execute ':vimgrep /'.escape(getreg('/'), '.').'/g %'<CR>
572 \ :copen<CR>
573
574 menu &Changes.list
575 \<Tab>:changes
576 \ :changes<CR>
577 menu &Changes.-Sep- :
578 menu &Changes.previous
579 \<Tab>g;
580 \ g;
581 menu &Changes.next
582 \<Tab>g,
583 \ g,
584 menu &List.location.signs\ to\ list
585 \<Tab>CMD
586 \ :execute ":call setloclist(0, map(get(getbufinfo('%')[0], 'signs'), {_, p->extend(p, {'bufnr':buffer_number('.'), 'text':get(p, 'name')})}))"<CR>
587 menu &List.location.list\ to\ signs
588 \<Tab>CMD
589 \ :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>
590 menu &Jump.list
591 \<Tab>:jumps
592 \ :jumps<CR>
593 menu &Jump.-Sep1- :
594 menu &Jump.previous\ position
595 \<Tab>CTRL-O
596 \ <C-O>
597 menu &Jump.next\ position
598 \<Tab>CTRL-I
599 \ <C-I>
600 menu &Jump.-Sep2- :
601 menu &Jump.clear\ list
602 \<Tab>:clearjumps
603 \ :clearjumps
604
605 1000menu &Tag.list
606 \<Tab>:tags
607 \ :tags<CR>
608 1000menu &Tag.selection\ list
609 \<Tab>:ts
610 \ :ts<CR>
611
612 1000menu &Tag.-Sep1- :
613
614 1000menu &Tag.stack.jump\ older
615 \<Tab><C-T>
616 \ :po
617 1000menu &Tag.stack.jump\
618 \<Tab>:ta
619 \ :ta
620 endif
621
622 " autocmd BufEnter * @f
623 augroup END
624
625 " autocmd VimEnter * set nobuflisted
626endif
627
628
629" ======================================================================================================================
630" SHORTCUTS: custom shortcuts
631" inoremap <C-Space> <C-x><C-o>
632" inoremap <C-@> <C-Space>
633
634" Bind CTRL+Backspace to vim's version (CTRL+W) in " <CR> insert mode (only works with gvim)
635inoremap
636 \ <C-Backspace>
637 \ <C-W>
638
639" INDENTATION: allows un-indenting a selected block and keeps selection
640vnoremap < <gv
641vnoremap > >gv
642
643" make shift-home select to the beginning of the line
644nnoremap <s-home> v^
645nnoremap <s-end> v$
646
647nnoremap <s-down> vj
648vnoremap <s-down> j
649nnoremap <s-up> vk
650vnoremap <s-up> k
651
652
653" close current buffer with <leader>q...
654nnoremap <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>.
655" google the word under the cursor
656nnoremap <leader>G :execute ":!xdg-open https://google.de/search?q=".expand("<cword>")
657
658nnoremap <silent> <F5> :make!<CR>
659nnoremap <silent> <F6> :silent syntax sync fromstart<CR>:nohlsearch<CR>:silent match<CR>:silent 2match<CR>:silent 3match<CR>
660nnoremap <leader>r :syntax sync fromstart
661
662nnoremap <silent> <A-Up> :wincmd k<CR>
663nnoremap <silent> <A-Down> :wincmd j<CR>
664nnoremap <silent> <A-Left> :wincmd h<CR>
665nnoremap <silent> <A-Right> :wincmd l<CR>
666
667" INSERT_MODE_MAPPINGS:
668" default copy&paste insert key binding (just in insert mode, so it doesn't conflict
669" with visual block mode)- would have been nice, but collides with c-w for digraphs
670" inoremap <C-V> <C-R>+
671"
672inoremap <C-S> <C-O>:w<CR>
673
674" NEOVIM_SPECIFIC:
675if has('nvim') " only neovim...
676 " shortcut \t opens a terminal in a horizontal split
677 nnoremap <leader>t :new +terminal<CR>
678endif
679
680
681
682" ======================================================================================================================
683" START: LOADING PLUGINS
684" ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
685call plug#begin()
686" Colorschemes:
687Plug 'coderonline/vim-remote-menu'
688" Plug 'bbchung/clighter8'
689" Plug 'octol/vim-cpp-enhanced-highlight'
690" Plug 'vim-scripts/TagHighlight'
691" if ! exists('g:TagHighlightSettings')
692" let g:TagHighlightSettings = {}
693" endif
694" let g:TagHighlightSettings['TagFileName'] = 'tags'
695" let g:TagHighlightSettings['CtagsExecutable'] = 'ctags'
696
697Plug 'chriskempson/base16-vim' | " not just one high quality color scheme (all named base16-*)
698Plug 'NLKNguyen/papercolor-theme' | " the one I like the most
699
700Plug 'mhinz/vim-signify' | " uses the sign column to indicate added, modified and removed lines
701Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin
702Plug 'godlygeek/tabular' | " align code on a sign, like :Tab/=
703Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with '
704let g:signify_vcs_list = [ 'git' ] | " use signify only with git (improves speed when loading buffers, see :h signify)
705let g:signify_cursorhold_insert = 0
706let g:signify_cursorhold_normal = 0
707let g:signify_update_on_bufenter = 0
708let g:signify_update_on_focusgained = 0
709let g:signify_sign_show_count = 0
710
711let g:signify_sign_add = '➕'
712let g:signify_sign_delete = '➖'
713let g:signify_sign_delete_first_line = '➖'
714let g:signify_sign_change = '❗'
715let g:signify_sign_changedelete = g:signify_sign_change
716
717
718" NERDTree: replaces NetRW, as long as it has so many bugs
719Plug 'scrooloose/nerdtree' | "
720let NERDTreeIgnore = ['\.aux$', '\.o$']
721let NERDTreeCascadeSingleChildDir = 0 | " I don't get how one can use <m> to create files in that included directory
722let NERDTreeChDirMode = 0
723let NERDTreeHiddenFirst = 1
724let NERDTreeMinimalUI = 1
725let NERDTreeShowBookmarks = 1 | " show bookmarks by default (when opening for the first time)
726let NERDTreeWinSize = 40
727let NERDTreeQuitOnOpen = 1
728
729" depending on if NERDTree has the focus:
730nnoremap <expr>
731 \ <leader><leader>
732 \ bufwinnr("%")==g:NERDTree.GetWinNum() ? ':NERDTreeClose<CR>' : ':NERDTreeFind<CR>'
733nnoremap <expr>
734 \ <F2>
735 \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':N<CR>'
736
737nnoremap <expr>
738 \ <F3>
739 \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':n<CR>'
740
741nnoremap <F4>
742 \ :wincmd c<CR>
743" close NERDTree if it is the last remaining window (taken from the official documentation)
744" autocmd bufenter *
745" \ if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
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" indent within <script> and <style> (default is a zero indent)
755let g:html_indent_script1 = "inc"
756let g:html_indent_style1 = "inc"
757
758Plug 'majutsushi/tagbar' " superseeds taglist-plus, which isn't maintained any more
759let g:tagbar_autoclose = 0
760let g:tagbar_autofocus = 1
761let g:tagbar_autoshowtag = 0
762let g:tagbar_compact = 1
763let g:tagbar_indent = 0
764let g:tagbar_foldlevel = 99
765
766nnoremap <F9> :TagbarToggle<CR>| " bind TagBar to hotkey F9
767
768" Autocompleter: =====================================
769if has("python") || has('python3')
770
771 " ULTISNIPS: code snippet ============================================================================================
772 Plug 'honza/vim-snippets' " dependency of ultisnips (see below)
773 Plug 'SirVer/ultisnips' " replaces loremipsum (and many more)
774 " 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)
775 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)
776
777 let g:UltiSnipsJumpForwardTrigger = '<Tab>'|
778 let g:UltiSnipsJumpBackwardTrigger = '<S-Tab>'|
779 "d let g:UltiSnipsJumpForwardTrigger = '<PageDown>'
780 " let g:UltiSnipsJumpBackwardTrigger = '<PageUp>'
781 "let g:UltiSnipsExpandTrigger = '<C-j>'| " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
782 "let g:UltiSnipsJumpForwardTrigger = '<C-j>'| " \
783 "let g:UltiSnipsJumpBackwardTrigger = '<C-k>'| " \
784 "let g:UltiSnipsListSnippets = '<C-`>'| " YouCompleteMe includes those, so this isn't necessary
785 "let g:UltiSnipsListSnippets = '<leader><leader>'| " YouCompleteMe includes those, so this isn't necessary
786 """ Ultisnips
787 " let g:UltiSnipsExpandTrigger="<c-tab>"
788 " let g:UltiSnipsListSnippets="<c-s-tab>"
789
790 if has('nvim')
791 Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
792 " Use deoplete.
793 let g:deoplete#enable_at_startup = 1
794 inoremap <silent><expr> <C-Space> deoplete#mappings#manual_complete()
795
796 Plug 'Shougo/echodoc.vim'
797 let g:echodoc#enable_at_startup = 1
798
799 " Plug 'Rip-Rip/clang_complete'
800 " Plug 'tweekmonster/deoplete-clang2'
801 " Plug 'zchee/deoplete-clang'
802 " let g:deoplete#sources#clang#libclang_path = "/usr/lib/libclang.so"
803 " let g:deoplete#sources#clang#clang_header = "/usr/lib/clang/6.0.0"
804 " let g:deoplete#sources#clang#std#cpp = 'c++1z'
805 " let g:deoplete#sources#clang#clang_complete_database = "/home/max/src"
806 " Plug 'Shougo/neoinclude.vim' " makes vim slow - unfortunatelly
807
808 " Plug 'Shougo/deoplete-clangx' " mentioned in Q&A of deoplete
809 Plug 'autozimu/LanguageClient-neovim', {
810 \ 'branch': 'next',
811 \ 'do': 'bash install.sh',
812 \ }
813
814 let g:LanguageClient_serverCommands = {
815 \ 'cpp': ['clangd'],
816 \ 'c': ['clangd']
817 \ }
818 " Plug 'roxma/nvim-completion-manager' unmaintained python version
819 else
820 " YouCompleteMe: =====================================================================================================
821 " Plug 'Valloric/MatchTagAlways' " highlights the closing tag/brace/...
822 Plug 'Valloric/YouCompleteMe', {
823 \ 'do' : 'python install.py --clang-completer --system-libclang --quiet',
824 \ }
825 let g:ycm_error_symbol = '✖' " insert this as an error symbol in the gutter bar/sign column
826 let g:ycm_warning_symbol = '➔' " insert this as a warning symbol in the gutter bar/sign coloumn
827
828 let g:ycm_autoclose_preview_window_after_insertion = 0
829 let g:ycm_auto_trigger = 1
830 let g:ycm_collect_identifiers_from_tags_files = 1 " Let YCM read tags from Ctags file
831 let g:ycm_confirm_extra_conf = 0 " security is overrated ;)
832 let g:ycm_always_populate_location_list = 0 " we can manually run :YcmDiags to do that
833
834 let g:ycm_key_list_previous_completion = ['Up']
835 let g:ycm_key_list_select_completion = ['Down']
836
837 let g:ycm_semantic_triggers = {
838 \ 'c': [ 're!\w{2}' ]
839 \ }
840
841 " Plug 'vim-scripts/dbext.vim' " dependency to allow db related completions
842 " let g:ycm_server_python_interpreter = 'python3'
843 " let g:ycm_python_binary_path = '/usr/bin/python3' " the python interpreter of choice (for code checking)
844 " let g:ycm_add_preview_to_completeopt = 1 " reuse existing preview window
845 " let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword
846 " let g:ycm_complete_in_comments = 1 " Completion in comments
847 " let g:ycm_complete_in_strings = 1 " Completion in string
848 " 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!)
849 " let g:ycm_min_num_identifier_candidate_chars = 4
850 " let g:ycm_max_num_identifier_candidates = 10
851 " let g:ycm_max_num_candidates = 50
852 " let g:ycm_use_ultisnips_completer = 1 " Default 1, just ensure
853 " let g:ycm_key_list_select_completion = ['<Down>']
854 " let g:ycm_key_list_previous_completion = ['<Up>']
855 " let g:ycm_global_ycm_extra_conf = '.ycm_extra_conf.py'
856 " let g:ycm_semantic_triggers = { 'c': [ 're!.' ] }
857 " let g:ycm_disable_for_files_larger_than_kb = 16384 " we have faaast computers, don't we?
858 " let g:ycm_show_diagnostics_ui = 0
859 " " disable <tab>-key for YCM so that it can be used with ultisnips
860 " let g:ycm_key_list_select_completion=[]
861 " let g:ycm_key_list_previous_completion=[]
862 endif
863
864
865 " SYNTASTIC: =========================================================================================================
866 if has('nvim')
867 Plug 'w0rp/ale'
868 let g:ale_set_highlights = 0
869 highlight! link ALEWarningSign FoldColumn
870 let g:ale_sign_error = ''
871 let g:ale_sign_style_error = ''
872 let g:ale_sign_info = ''
873 let g:ale_sign_warning = ''
874 else
875 Plug 'scrooloose/syntastic'
876 " set statusline+=%#warningmsg#
877 " set statusline+=%{SyntasticStatuslineFlag()}
878 let g:LatexBox_latexmk_preview_continuously = 1
879 let g:LatexBox_viewer = "evince"
880 let g:syntastic_always_populate_loc_list = 1
881 let g:syntastic_auto_loc_list = 0
882 let g:syntastic_check_on_open = 1
883 let g:syntastic_check_on_wq = 0
884 " let g:syntastic_quiet_messages = {"type":"style"}
885 "
886 " E221: multiple spaces before Operator
887 let g:syntastic_python_flake8_args = '--max-complexity=10 --max-line-length=120 --exclude venv --doctests --exit-zero --ignore=E221'
888 " filter ( = do not display) style/formatting errors and warnings
889 let g:syntastic_error_symbol = '✖'
890 let g:syntastic_style_error_symbol = '✗'
891 let g:syntastic_warning_symbol = '➔'
892 let g:syntastic_style_warning_symbol = '≈'
893 endif
894
895 " JEDI: ==============================================================================================================
896 Plug 'davidhalter/jedi-vim' " jedi gets used to display python function signatures
897 let g:jedi#completions_enabled = 0 " we do not need completions, because we have YouCompleteMe
898 let g:jedi#show_call_signatures = 1 " which sadly does not support signatures like jedi
899 let g:jedi#show_call_signatures_delay = 0
900 let g:jedi#auto_vim_configure = 0
901 let g:pymode_rope = 0 " https://github.com/davidhalter/jedi-vim/issues/163
902 " autocmd FileType python jedi.preload_module('os', 'sys', 'math')
903 " let g:pymode_options_max_line_length = 120
904 " let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301'
905
906endif " has("python")
907
908"=======================================================================================================================
909" TESTING: | " plugins which I am currently trying...
910"=======================================================================================================================
911" Plug 'rhysd/vim-clang-format' | unnecessary, because we can just :pyf /usr/share/clang/clang-format.py
912Plug 'kana/vim-operator-user' " dependency, which allows overriding the = operator for indentation
913
914" TODO: check if this is unrequired, when set equalprog is set to that py file
915autocmd FileType c,cpp,objc map <buffer> = :pyf /usr/share/clang/clang-format.py<CR>
916
917" let g:clang_format#detect_style_file = 1
918" autocmd FileType c,cpp,objc map <buffer> = <Plug>(operator-clang-format)
919
920" Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values)
921" Plug 'rkitover/vimpager'
922" found this command instead (use as PAGER):
923" man -P 'nvim -R -u NORC -c":%!col -b" -c":set buftype=nowrite filetype=man" -' ls
924
925command BuffersToArg :exec ':args '.join(map(range(0, bufnr('$')), 'fnameescape(fnamemodify(bufname(v:val), ":."))'))
926command BufToArg :argadd %:.
927command Gbranch call setqflist([], 'r', {'title':'Git branch selector','items':map(systemlist("git branch"), {_, p->{'filename':'branch','module': fnamemodify(p, ':.')}})})
928
929" the following command opens a preview-window and shows the declaration of
930" the function under the cursor. It also highlights the word to make it easier
931" to spot within a great file
932command Helpme au! CursorHold * nested let @/=expand('<cword>')|exe "silent! psearch ".expand("<cword>")
933
934"=======================================================================================================================
935call plug#end() | " all plugins are getting loaded on this line, don't remove!
936
937" ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
938" END: LOADING PLUGINS
939" ======================================================================================================================
940
941" Deprecated with this configuration, but still useful when deactivating some Plugins
942" NETRW: obsolete with NERDTree
943let g:netrw_alto = 0 | " open files on the right
944let g:netrw_altv = 1 | " open files on the right
945let g:netrw_banner = 0 | " display help messages?
946let g:netrw_browse_split = 4 | " 4=open in previous window
947let g:netrw_fastbrowse = 2 | " manually refresh direcory list (avoids display errors)
948let g:netrw_hide = 1 | " show not-hidden files only
949let g:netrw_keepdir = 0
950let g:netrw_list_hide = '^\..*' | " Explore mode: hide files starting with dot
951let g:netrw_liststyle = 3 | " 3=tree
952let g:netrw_preview = 0 | "
953let g:netrw_winsize = 20 | " window size in percent
954
955" ======================================================================================================================
956" COLORSCHEME:
957" ======================================================================================================================
958
959function! ExtendColorTheme()
960 filetype on
961 filetype plugin on
962 filetype indent on
963
964 syntax on | " enable syntax highlighting
965 syntax sync minlines=60 | " how many preceding lines will be parsed? (has performance impact)
966
967 highlight! SignifySignAdd ctermbg=NONE
968 highlight! Bold cterm=bold gui=bold
969 highlight! Italic cterm=italic gui=italic
970 highlight! Underline cterm=underline gui=underline
971 highlight! BoldUnderline cterm=bold,underline gui=bold,underline
972 highlight! BoldItalic cterm=bold,Italic gui=Bold,Italic
973 highlight! Todo cterm=bold gui=bold guibg=#ffffaa guifg=#000000
974 highlight! Error ctermbg=NONE guibg=NONE
975 highlight! SpellBad cterm=NONE gui=undercurl guibg=NONE guifg=red
976
977
978 highlight! link SpecialKey NonText | " makes tab stop (see listchars) less disturbing
979 highlight! link EndOfBuffer Ignore
980 highlight! link WildMenu Search
981 highlight! link Convention Error
982 highlight! link YcmErrorSign SpellBad
983 highlight! link YcmWarningSign Spellbad
984 highlight! link SignifySignAdd SignColumn
985 highlight! link SignifySignChange SignColumn
986 highlight! link SignifySignDelete SignColumn
987 highlight! link SignifySignChangeDelete SignColumn
988 highlight! link SignifySignDeleteFirstLine SignColumn
989 highlight! link VertSplit NonText
990 highlight! link LineNr Comment
991 highlight! link Folded LineNr
992 highlight! link SignColumn Comment
993 highlight! link FoldColumn Comment
994 highlight! link PmenuSbar Pmenu
995 highlight! PmenuThumb cterm=inverse
996 highlight! MoreMsg cterm=inverse
997
998 autocmd InsertEnter * silent! call matchdelete(101)
999 autocmd InsertLeave * silent! call matchadd('Convention', ' \+$', -1, 101, { 'conceal': '⟶' })
1000
1001 autocmd InsertEnter * set colorcolumn=80,120
1002 autocmd InsertLeave * set colorcolumn&
1003
1004 " execute 'highlight! StatusLine'
1005 " \ .' guibg=NONE'
1006 " \ .' guifg='.g:status_bg
1007 " \ .' gui=inverse'
1008 " let g:status_fg=synIDattr(hlID('Cursor'), 'fg#')
1009 " let g:status_bg=synIDattr(hlID('Cursor'), 'bg#')
1010 " let g:status_sel=synIDattr(hlID('Text'), 'fg#')
1011 " let g:status_sel='#ffffff'
1012 " " execute 'highlight! User1 gui=NONE'
1013 " execute 'highlight! User1 guibg='.g:status_sel
1014 " execute 'highlight! User1 guifg='.g:status_fg
1015 " execute 'highlight! User2 gui=NONE'
1016 " execute 'highlight! User2 guibg='.g:status_sel
1017 " execute 'highlight! User2 guifg=NONE'
1018 " use the default terminal background color as background (allows transparency)
1019 " highlight! Normal guibg=NONE ctermbg=NONE
1020 " highlight! NonText guibg=NONE guifg=black ctermbg=NONE ctermfg=black
1021 " makes the ~ (tilde) indicator invisible, which usually marks the EOF
1022 " highlight! CursorLineNr cterm=inverse | " ctermbg=black ctermfg=NONE
1023 " highlight! Pmenu ctermbg=LightYellow ctermfg=DarkGrey
1024 " highlight! PmenuSel ctermbg=blue ctermfg=LightYellow cterm=bold
1025 " highlight! Folded ctermbg=NONE
1026 " highlight! Cursor guibg=#729fcf ctermbg=yellow
1027 " highlight! SpellBad ctermbg=none
1028 " highlight! SpecialKey ctermfg=19
1029 " highlight! WhiteSpace ctermfg=19
1030 " highlight! link TabLine LineNr
1031 " highlight! TabLineSel ctermbg=blue ctermfg=black
1032 " highlight! link TabLineFill LineNr
1033 " highlight! Search ctermbg=LightYellow ctermfg=12 guibg=#fefd86 guifg=#222222
1034 " generic, which should exist but don't
1035 " autocmd InsertLeave * call matchadd('Conceal', ' \+$', -1, 101, { 'conceal': '⟶' })
1036 " Show trailing whitepace and spaces before a tab as part of the syntax highlighting
1037 " autocmd BufEnter,InsertLeave * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL
1038 " autocmd Syntax * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL
1039 " autocmd BufEnter,BufWritePost * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL
1040 " autocmd InsertEnter * syntax clear Convention
1041 " autocmd BufEnter,InsertLeave * execute ':syntax match Convention /\%>'.&textwidth.'v./ containedin=ALL'
1042 " set colorcolumn= | " not used, because we have a :match directive for textwidth
1043" if argc() == 0
1044 " rv
1045 " autocmd VimEnter * split +bro\ ol
1046 " endif
1047endfunction
1048autocmd! ColorScheme * call ExtendColorTheme()
1049
1050
1051
1052" ======================================================================================================================
1053" CONVENIENCE:
1054" ======================================================================================================================
1055command Vimls
1056 \ call setloclist(0, map(getbufinfo({'buflisted':1}),
1057 \ "{'bufnr': v:val.bufnr,
1058 \ 'lnum': v:val.lnum,
1059 \ 'text': '='.printf('%*s, % 3d: %s [%s]', winwidth(0) / 2, '', v:val.bufnr, v:val.name, getbufvar(v:val.bufnr, '&buftype')),
1060 \ 'pattern': 'not loaded'}
1061 \ "))
1062
1063command Ctoggle
1064 \ if(get(getqflist({'winid':1}), 'winid') == win_getid())|cclose|else|botright copen|endif
1065command Ltoggle
1066 \ if(get(getloclist(0, {'winid':1}), 'winid') == win_getid())|lclose|else|lopen|endif
1067
1068
1069
1070" nnoremap <silent> <ESC> :lclose<CR> " brings vim into REPLACE mode (R)
1071nnoremap <silent> <F7> :Ltoggle<CR>
1072nnoremap <silent> <F8> :Ctoggle<CR>
1073nnoremap <silent> <F12> :Vimls<CR>:Ltoggle<CR>
1074
1075" exec current line as a command, insert output of command (from: https://youtu.be/MquaityA1SM?t=35m45s)
1076nnoremap Q !!$SHELL<CR>
1077
1078
1079" ======================================================================================================================
1080" TESTING:
1081" ======================================================================================================================
1082autocmd TextYankPost * echo '> text yanked to '.(
1083 \ get(v:event,'regname') == ''
1084 \ ? 'default register'
1085 \ : 'register '.get(v:event,'regname'))
1086
1087autocmd VimEnter,WinEnter * exec ':set scrolljump='.winheight(0)/2
1088
1089" display highlight group under the cursor
1090map <leader>h :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<CR>
1091
1092if filereadable(expand("~/.vimrc_background")) && filereadable(expand("~/.config/base16-shell/colortest"))
1093 let g:base16_shell_path="~/.config/base16-shell/scripts"
1094 let base16colorspace=256
1095 " let syntax_cmd="skip" " vim internal, use base16 and no default colors
1096 set background=dark
1097 source ~/.vimrc_background
1098else
1099 let g:PaperColor_Theme_Options = {
1100 \ 'theme': {
1101 \ 'default': {
1102 \ 'transparent_background': 0
1103 \ }
1104 \ }
1105 \ }
1106 set background=light
1107 colorscheme PaperColor
1108endif
1109
1110
1111augroup status
1112 set noshowmode | " mode will be shown twice, in lightline and below, so we want to deactivate one
1113 set laststatus=2 | " required by AirLine and Lightline, without status line does not appear until a window split
1114
1115 let g:status_sym_start = ''
1116 let g:status_sym_end = ''
1117 let g:status_sym_sep_start = ''
1118 let g:status_sym_sep_end = ''
1119 let g:symbol_branch = ''
1120
1121 if &term == "linux"
1122 let g:symbol_branch = ''
1123
1124 let g:group_active = "StatusLineTerm"
1125 let g:group_inactive = "StatusLineTermNC"
1126 let g:group_tabline = "StatusLineTerm"
1127 else
1128 let g:group_active = "StatusLine"
1129 let g:group_inactive = "StatusLineNC"
1130 let g:group_tabline = "TabLine"
1131 endif
1132
1133 " this function reverts foreground color and background color of a given
1134 " highlight group and returns the name of a newly created _invert group
1135 function! CreateInvertGroup(highlight_group)
1136 if(synIDattr(hlID(a:highlight_group), "reverse")==1)
1137 let w:color=synIDattr(hlID(a:highlight_group), "fg#")
1138 else
1139 let w:color=synIDattr(hlID(a:highlight_group), "bg#")
1140 endif
1141
1142 let l:retval=a:highlight_group.'_invert'
1143 if(exists('w:color') && w:color == '')
1144 let w:color = 'NONE'
1145 endif
1146 silent! exec 'highlight '.retval.' gui=NONE guifg='.w:color.' cterm=NONE ctermfg='.w:color
1147 return l:retval
1148 endfunction
1149
1150 function! UpdateStatus(highlight_group)
1151 let l:invert_group = CreateInvertGroup(a:highlight_group)
1152 let l:mode = get({
1153 \ 'n' : 'normal',
1154 \ 'i' : 'insert',
1155 \ 'R' : 'replace',
1156 \ 'v' : 'visual',
1157 \ "V" : 'visual line',
1158 \ "\<C-V>" : 'visual block',
1159 \ 'c' : 'command',
1160 \ 's' : 'select',
1161 \ 'S' : 'select line',
1162 \ "\<C-s>" : 'select block',
1163 \ 't' : 'terminal'
1164 \ }, mode(), mode())
1165 return ''
1166 \ ."%#StatusLineHighlight#"
1167 \ ."%#".a:highlight_group."#"
1168 \ ."%(%w%h%q%)".' '.l:mode.' '.g:status_sym_sep_start.' '
1169 \ ."%{(argc()>0\ ?\ argidx()+1.':'.argc().' '.g:status_sym_sep_start.' '\ :\ '')}"
1170 \ ."%{winbufnr(0).' '.g:status_sym_sep_start}"
1171 \ ."%{(&readonly\ ?\ '\ \ 🔒'\ :\ '')}"
1172 \ ."%{(&modified\ ?\ '\ \ '.nr2char(0xF0C7).'\ '\ :\ '')\ }"
1173 \ ."%{(haslocaldir() ?\ fnamemodify(getcwd(),\ ':.').' '.nr2char(0xe0b1)\ \:\ '')}\ "
1174 \ ."%{(&buftype\ ==\ \"terminal\"\ ?\ has('nvim')?b:term_title:expand(&titlestring)\ :\ substitute(expand('%:p'),\ '^'.getcwd(-1).'/*',\ '',\ ''))\ }"
1175 \ ."%1(%)"
1176 \ ."%#".l:invert_group."#"
1177 \ .g:status_sym_end
1178 \ .''
1179 \ ."%="
1180 \ .''
1181 \ ."%#".l:invert_group."#"
1182 \ .g:status_sym_start
1183 \ ."%#".a:highlight_group."#"
1184 \ ."%1(%)"
1185 \ ."%{(&filetype\ !=\ ''\ ?\ &filetype\ :\ &buftype)}"
1186 \ ."%(\ %{g:status_sym_sep_end}\ %)"
1187 \ ."%{(&spell\ ?\ &spelllang.' '.g:status_sym_sep_end\ :\ '')}"
1188 \ ."%{(&fileencoding\ !=\ ''\ ?\ &fileencoding.' '.g:status_sym_sep_end.' '\ :\ '')}"
1189 \ ."%{(&fileformat\ !=\ ''\ ?\ ' '.&fileformat.' '\ :\ '')}"
1190 \ .g:status_sym_sep_end.' '
1191 \ ."%4l:%-3c"
1192 \ .g:status_sym_sep_end.' '
1193 \ ."%-3p%%"
1194 endfunction
1195
1196 function! UpdateTabline(highlight_group)
1197 let l:invert_group = CreateInvertGroup(a:highlight_group)
1198 return ''
1199 \ ."%#".a:highlight_group."#"
1200 \ ."%3( \ %)\ "
1201 \ ."%{getcwd(-1)}\ "
1202 \ .g:status_sym_sep_start.' '
1203 \ ."%(\ ".g:symbol_branch."\ %{fugitive#head()}\ %)"
1204 \ ."%#".l:invert_group."#"
1205 \ .g:status_sym_end
1206 \ .''
1207 \ ."%="
1208 \ .''
1209 \ ."%#".l:invert_group."#"
1210 \ .g:status_sym_start
1211 \ ."%#".a:highlight_group."#"
1212 \ ."%3(\ %)"
1213 \ ."%(%{v:servername}\ %{v:this_session}%)"
1214 \ .g:status_sym_sep_end.' '
1215 \ ."%(\ \ %{tabpagenr()}/%{tabpagenr('$')}\ %)"
1216 \ ."%##"
1217 \ ."" " end
1218 endfunction
1219
1220 function! ApplyColorScheme()
1221 " set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incompatible with nvim
1222 " set t_ut=
1223 " set up statusline, global and current window individually
1224 set statusline=%!UpdateStatus(g:group_inactive)
1225 setlocal statusline=%!UpdateStatus(g:group_active)
1226 " set up the tabline (match colors)
1227 set tabline=%!UpdateTabline(g:group_tabline)
1228 endfunction
1229 " apply colors from the loaded colorscheme...
1230 " when changing the colorscheme also apply new colors to the statusbar...
1231 autocmd VimEnter,ColorScheme * call ApplyColorScheme()
1232
1233 autocmd WinEnter * setlocal statusline=%!UpdateStatus(g:group_active)
1234 autocmd WinLeave * setlocal statusline<
1235augroup END " status
1236
1237" moved after VimEnter of statusline, so that it does not get overwritten any
1238" more
1239if empty(argv())
1240
1241 " autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val}))
1242
1243 " from the list of recent files: make absolute paths, filter out files not
1244 " contained in cwd and finally filter out directories and non-files...
1245 autocmd StdinReadPre * let s:std_in=1
1246 autocmd VimEnter * if !exists("s:std_in") | call setloclist(0, [], 'r',
1247 \ {
1248 \ 'title':'Recently used files in directory: '.getcwd(),
1249 \ 'items':map(filter(filter(
1250 \ map(copy(v:oldfiles),
1251 \ {_, p->expand(p)}), 'v:val =~ "'.getcwd().'/"'), 'filereadable(v:val)'),
1252 \ {_, p->{'filename': fnamemodify(p, ':.')}})
1253 \ }) | lopen | only | setfiletype qf
1254endif
1255
..