diff --git a/vimrc b/vimrc index 43f6c1a..d4f666d 100644 --- a/vimrc +++ b/vimrc @@ -743,6 +743,7 @@ let g:tagbar_sort = 0 "################################################################################## let g:gitgutter_enabled = 1 let g:gitgutter_highlight_lines = 0 + nnoremap hh :GitGutterToggle nmap ha (GitGutterStageHunk) nmap [h (GitGutterNextHunk) @@ -1079,6 +1080,12 @@ let errormarker_errorgroup = "BuildError" let errormarker_warninggroup = "BuildWarn" let errormarker_infogroup = "BuildInfo" +" I don't know how to map to a plugin command, so I'm wrapping it with a function...ugh. +function! ShowErrorAtCursor() + " This is defined in errormarker.vim + ErrorAtCursor +endfunction +nnoremap ce :call ShowErrorAtCursor() "///////////////////////////////////////////////// " CUSTOM ERROR FORMATS @@ -1405,20 +1412,59 @@ noremap n :call RenameFile() "################################################################################## function! CenterPane() - " centers the current pane as the middle 2 of 4 imaginary columns - " should be called in a window with a single pane + " Centers the current pane as the middle 2 of 4 imaginary columns should + " be called in a window with a single pane. " Taken from https://dev.to/vinneycavallo/easily-center-content-in-vim lefta vnew wincmd w exec 'vertical resize' string(&columns * 0.65) endfunction -nnoremap c :call CenterPane() function! RemoveCenterPane() wincmd w close endfunction -nnoremap cw :call RemoveCenterPane() + +nnoremap cc :call CenterPane() +nnoremap cd :call RemoveCenterPane() + + +"################################################################################## +" SIMPLE VIEW +"################################################################################## + +" Applies a clean view of the current buffer by turning off line +" numbers, trailing spaces, tabs and git diff markers in the gutter. + +function! ToggleSimpleView() + " I wasn't able to get this to apply to every copy of the same buffer, + " e.g. you have a split view showing the same file; only the active one + " will be affected, but they will share the same state! I tried many + " different approaches (bufdo, looping over windows and buffers) and + " nothing worked. I looked at the gitgutter plugin since it supports + " toggling a buffer and it correctly modifies all instances, but the code + " is complex and there's so much just to do a simple thing. Fuck it. It's + " not worth the hassle and the inevitable hair pulling that I always + " experience when trying to do non-trivial things with this garbage + " scripting language. + if ! exists("b:simple_view_enabled") + let b:simple_view_enabled = 0 + endif + + if b:simple_view_enabled == 0 + let b:simple_view_enabled = 1 + setlocal nonumber + setlocal nolist + exec 'GitGutterBufferDisable' + else + let b:simple_view_enabled = 0 + setlocal number + setlocal list + exec 'GitGutterBufferEnable' + endif +endfunction + +nnoremap c :call ToggleSimpleView() "-----------------------------------------------------------------------------------------------------------------------