Add a vim function to toggle a 'simple' view of the current buffer
This commit is contained in:
parent
7e586d284d
commit
f0248008a6
54
vimrc
54
vimrc
|
@ -743,6 +743,7 @@ let g:tagbar_sort = 0
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
let g:gitgutter_enabled = 1
|
let g:gitgutter_enabled = 1
|
||||||
let g:gitgutter_highlight_lines = 0
|
let g:gitgutter_highlight_lines = 0
|
||||||
|
|
||||||
nnoremap <leader>hh :GitGutterToggle<cr>
|
nnoremap <leader>hh :GitGutterToggle<cr>
|
||||||
nmap <leader>ha <Plug>(GitGutterStageHunk)
|
nmap <leader>ha <Plug>(GitGutterStageHunk)
|
||||||
nmap [h <Plug>(GitGutterNextHunk)
|
nmap [h <Plug>(GitGutterNextHunk)
|
||||||
|
@ -1079,6 +1080,12 @@ let errormarker_errorgroup = "BuildError"
|
||||||
let errormarker_warninggroup = "BuildWarn"
|
let errormarker_warninggroup = "BuildWarn"
|
||||||
let errormarker_infogroup = "BuildInfo"
|
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 <leader>ce :call ShowErrorAtCursor()<cr>
|
||||||
|
|
||||||
"/////////////////////////////////////////////////
|
"/////////////////////////////////////////////////
|
||||||
" CUSTOM ERROR FORMATS
|
" CUSTOM ERROR FORMATS
|
||||||
|
@ -1405,20 +1412,59 @@ noremap <leader>n :call RenameFile()<cr>
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
|
|
||||||
function! CenterPane()
|
function! CenterPane()
|
||||||
" centers the current pane as the middle 2 of 4 imaginary columns
|
" Centers the current pane as the middle 2 of 4 imaginary columns should
|
||||||
" should be called in a window with a single pane
|
" be called in a window with a single pane.
|
||||||
" Taken from https://dev.to/vinneycavallo/easily-center-content-in-vim
|
" Taken from https://dev.to/vinneycavallo/easily-center-content-in-vim
|
||||||
lefta vnew
|
lefta vnew
|
||||||
wincmd w
|
wincmd w
|
||||||
exec 'vertical resize' string(&columns * 0.65)
|
exec 'vertical resize' string(&columns * 0.65)
|
||||||
endfunction
|
endfunction
|
||||||
nnoremap <leader>c :call CenterPane()<cr>
|
|
||||||
|
|
||||||
function! RemoveCenterPane()
|
function! RemoveCenterPane()
|
||||||
wincmd w
|
wincmd w
|
||||||
close
|
close
|
||||||
endfunction
|
endfunction
|
||||||
nnoremap <leader>cw :call RemoveCenterPane()<cr>
|
|
||||||
|
nnoremap <leader>cc :call CenterPane()<cr>
|
||||||
|
nnoremap <leader>cd :call RemoveCenterPane()<cr>
|
||||||
|
|
||||||
|
|
||||||
|
"##################################################################################
|
||||||
|
" 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 <leader>c :call ToggleSimpleView()<cr>
|
||||||
|
|
||||||
"-----------------------------------------------------------------------------------------------------------------------
|
"-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user