aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Christian Pohle2018-04-15 17:37:39 +0200
committerMax Christian Pohle2018-04-15 17:37:39 +0200
commit7fbf4a822abb9d4d559f20c464cf3895333e0ea7 (patch)
tree1ee1461ea6e5b02faa0562256240498ed8df977e
parentc7a0281e3dc49dcea0df1f4edd8ee130b01872dc (diff)
downloadvim-karlmarks-7fbf4a822abb9d4d559f20c464cf3895333e0ea7.tar.bz2
vim-karlmarks-7fbf4a822abb9d4d559f20c464cf3895333e0ea7.zip
Refactoring: See 'convenience' section
-rw-r--r--vimrc-full98
1 files changed, 40 insertions, 58 deletions
diff --git a/vimrc-full b/vimrc-full
index 1a1b201..c6dc9d8 100644
--- a/vimrc-full
+++ b/vimrc-full
@@ -1,4 +1,4 @@
1" vim: noai:ts=2:sw=2:sts=2 iskeyword+=\:,\!,\<,\>,\-,\& 1" vim: noai:ts=2:sw=2:sts=2 iskeyword+=\:,\!,\<,\>,\-,\& number
2 2
3"======================================================================================================================= 3"=======================================================================================================================
4" GENERAL: 4" GENERAL:
@@ -9,6 +9,7 @@ set 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 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 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) 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
12 13
13 14
14set path+=** | " allow recursive searches for files 15set path+=** | " allow recursive searches for files
@@ -258,7 +259,6 @@ set sessionoptions+=winsize
258" set nocindent smartindent | " use smart indent rather then cindent 259" set nocindent smartindent | " use smart indent rather then cindent
259set noautoindent 260set noautoindent
260set nosmartindent 261set nosmartindent
261set cindent cinoptions+=(0 | " indent at parentheses
262 262
263set noshiftround | " indent/un-indent sna=ps to multiple of shiftwidths 263set noshiftround | " indent/un-indent sna=ps to multiple of shiftwidths
264set noequalalways | " do not evenly size windows when opening new or closing old 264set noequalalways | " do not evenly size windows when opening new or closing old
@@ -321,7 +321,6 @@ if has("autocmd")
321 " set omnifunc=syntaxcomplete#Complete 321 " set omnifunc=syntaxcomplete#Complete
322 322
323 augroup set_window_title " { 323 augroup set_window_title " {
324 " autocmd BufWinEnter quickfix setl statusline=%t
325 " autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]" 324 " autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]"
326 autocmd CursorHold * let &titlestring = "%t %y ".$USER."@".hostname().":%{expand(\"%:~:.:h\")}" 325 autocmd CursorHold * let &titlestring = "%t %y ".$USER."@".hostname().":%{expand(\"%:~:.:h\")}"
327 set title 326 set title
@@ -413,35 +412,6 @@ if has("autocmd")
413 " use the shada/viminfo file to return the cursor to where it was... 412 " use the shada/viminfo file to return the cursor to where it was...
414 autocmd BufReadPost * call setpos(".", getpos("'\"")) 413 autocmd BufReadPost * call setpos(".", getpos("'\""))
415 414
416
417 augroup ToggleQuickFix
418 function! ToggleQuickFix()
419 if exists("g:qwindow")
420 lclose
421 unlet g:qwindow
422 else
423 try
424 lopen 10
425 let g:qwindow = 1
426 catch
427 echo "No Errors found!"
428 endtry
429 endif
430 endfunction
431 function! QFixToggle(forced)
432 if exists("g:qfix_win") && a:forced == 0
433 cclose
434 unlet g:qfix_win
435 else
436 copen 10
437 let g:qfix_win = bufnr("$")
438 endif
439 endfunction
440
441 nmap <script> <silent> <F7> :call QFixToggle(0)<CR>
442 nmap <script> <silent> <F8> :call ToggleQuickFix()<CR>
443 augroup END
444
445 augroup CurrentFileName 415 augroup CurrentFileName
446 " highlight the current files name inside the document... 416 " highlight the current files name inside the document...
447 let @g = ":exe ':match SpellBad /'.escape(expand('%:t'), '.').'/'" 417 let @g = ":exe ':match SpellBad /'.escape(expand('%:t'), '.').'/'"
@@ -613,12 +583,6 @@ if has("autocmd")
613 \ :ta 583 \ :ta
614 endif 584 endif
615 585
616
617
618
619 " exec current line as a command, insert output of command (from: https://youtu.be/MquaityA1SM?t=35m45s)
620 nnoremap Q !!$SHELL<CR>
621
622 " autocmd BufEnter * @f 586 " autocmd BufEnter * @f
623 augroup END 587 augroup END
624 588
@@ -709,10 +673,6 @@ let g:signify_update_on_bufenter = 0
709let g:signify_update_on_focusgained = 0 673let g:signify_update_on_focusgained = 0
710let g:signify_sign_show_count = 1 674let g:signify_sign_show_count = 1
711 675
712" BUFEXPLORER: | " a buffer to list all buffers has the advantage, that default /-searches work in there
713Plug 'jlanzarotta/bufexplorer'
714nnoremap <F12> :ToggleBufExplorer<CR>
715
716" NERDTree: replaces NetRW, as long as it has so many bugs 676" NERDTree: replaces NetRW, as long as it has so many bugs
717Plug 'scrooloose/nerdtree' | " 677Plug 'scrooloose/nerdtree' | "
718let NERDTreeIgnore = ['\.aux$', '\.o$'] 678let NERDTreeIgnore = ['\.aux$', '\.o$']
@@ -819,8 +779,8 @@ let g:lightline = {
819 \ 'right': [] 779 \ 'right': []
820 \ }, 780 \ },
821 \ 'active': { 781 \ 'active': {
822 \ 'left': [ [ 'register', 'mode', 'paste' ], ['readonly', 'filetype'], [ 'absolutepath' ]], 782 \ 'left': [ [ 'mode', 'register', 'paste' ], [ 'absolutepath', 'title' ] , ['tagbar']],
823 \ 'right': [ [ 'lineinfo', 'percent' ], [ 'spell', 'fileencoding', 'fileformat' ] , ['tagbar'] ] 783 \ 'right': [ [ 'lineinfo', 'percent' ], [ 'filetype', 'readonly', 'spell', 'fileencoding', 'fileformat' ] ]
824 \ }, 784 \ },
825 \ 'component': { 785 \ 'component': {
826 \ 'tagbar': '%{substitute(tagbar#currenttag("%s", "", "fs"), "\(.*\)", "", "")}', 786 \ 'tagbar': '%{substitute(tagbar#currenttag("%s", "", "fs"), "\(.*\)", "", "")}',
@@ -832,7 +792,8 @@ let g:lightline = {
832 \ 'gitbranch': ' %{fugitive#head()}', 792 \ 'gitbranch': ' %{fugitive#head()}',
833 \ 'tabnumber': " %{tabpagenr()}/%{tabpagenr('$')}", 793 \ 'tabnumber': " %{tabpagenr()}/%{tabpagenr('$')}",
834 \ 'readonly': '%{&readonly ? "" : ""}', 794 \ 'readonly': '%{&readonly ? "" : ""}',
835 \ 'register': '%{v:register}' 795 \ 'register': '%{v:register}',
796 \ 'title': '%{getwinvar(0, "quickfix_title")}'
836 \ }, 797 \ },
837 \ 'component_expand': { 798 \ 'component_expand': {
838 \ 'buffercurrent': 'lightline#buffer#buffercurrent2', 799 \ 'buffercurrent': 'lightline#buffer#buffercurrent2',
@@ -889,9 +850,6 @@ if has("python")
889 " Plug 'Rip-Rip/clang_complete' 850 " Plug 'Rip-Rip/clang_complete'
890 Plug 'zchee/deoplete-clang' 851 Plug 'zchee/deoplete-clang'
891 Plug 'Shougo/neoinclude.vim' 852 Plug 'Shougo/neoinclude.vim'
892 Plug 'huawenyu/neogdb.vim'
893 let g:gdb_require_enter_after_toggling_breakpoint = 0
894 nmap <leader>v :call neobugger#gdb#Send("print " . expand('<cword>'))<CR>
895 else 853 else
896 Plug 'idanarye/vim-vebugger' 854 Plug 'idanarye/vim-vebugger'
897 855
@@ -1123,6 +1081,40 @@ else
1123 colorscheme PaperColor 1081 colorscheme PaperColor
1124endif 1082endif
1125 1083
1084" ======================================================================================================================
1085" CONVENIENCE:
1086" ======================================================================================================================
1087if empty(argv())
1088 " autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val}))
1089
1090 " from the list of recent files: make absolute paths, filter out files not
1091 " contained in cwd and finally filter out directories and non-files...
1092 autocmd StdinReadPre * let s:std_in=1
1093 autocmd VimEnter * if !exists("s:std_in") | call setqflist(map(filter(filter(
1094 \ map(copy(v:oldfiles), {_, p->expand(p)}), 'v:val =~ "'.getcwd().'"'),
1095 \ 'filereadable(v:val)'), {_, p->{'filename': fnamemodify(p, ':.')}})) | copen | only
1096endif
1097
1098command Vimls
1099 \ call setloclist(0, map(getbufinfo({'buflisted':1}),
1100 \ "{'bufnr': v:val.bufnr,
1101 \ 'lnum': v:val.lnum,
1102 \ 'text': '='.printf('%*s, % 3d: %s [%s]', winwidth(0) / 2, '', v:val.bufnr, v:val.name, getbufvar(v:val.bufnr, '&buftype')),
1103 \ 'pattern': 'not loaded'}
1104 \ "))
1105
1106command Ctoggle
1107 \ if(get(getqflist({'winid':1}), 'winid') == win_getid())|cclose|else|copen|endif
1108command Ltoggle
1109 \ if(get(getloclist(0, {'winid':1}), 'winid') == win_getid())|lclose|else|lopen|endif
1110
1111nnoremap <silent> <F7> :Ltoggle<CR>
1112nnoremap <silent> <F8> :Ctoggle<CR>
1113nnoremap <silent> <F12> :Vimls<CR>:Ltoggle<CR>
1114
1115" exec current line as a command, insert output of command (from: https://youtu.be/MquaityA1SM?t=35m45s)
1116nnoremap Q !!$SHELL<CR>
1117
1126 1118
1127" ====================================================================================================================== 1119" ======================================================================================================================
1128" TESTING: 1120" TESTING:
@@ -1137,13 +1129,3 @@ autocmd VimEnter,WinEnter * exec ':set scrolljump='.winheight(0)/2
1137" display highlight group under the cursor 1129" display highlight group under the cursor
1138map <leader>h :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<CR> 1130map <leader>h :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<CR>
1139 1131
1140if empty(argv())
1141 " autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val}))
1142
1143 " from the list of recent files: make absolute paths, filter out files not
1144 " contained in cwd and finally filter out directories and non-files...
1145 autocmd StdinReadPre * let s:std_in=1
1146 autocmd VimEnter * if !exists("s:std_in") | call setqflist(map(filter(filter(
1147 \ map(copy(v:oldfiles), {_, p->expand(p)}), 'v:val =~ "'.getcwd().'"'),
1148 \ 'filereadable(v:val)'), {_, p->{'filename': fnamemodify(p, ':.')}})) | copen | only
1149endif
..