nvim/init.auto-window.vim

35 lines
789 B
VimL

"auto_window_settings {{{
function! OnWinEnter() abort"{{{
if &buftype != ''
setlocal colorcolumn=0
elseif exists('b:colorcolumn_restore')
execute 'setlocal colorcolumn=' . b:colorcolumn_restore
endif
if &buftype == 'terminal'
setlocal nonumber norelativenumber
else
setlocal number relativenumber
endif
setlocal cursorline
setlocal cursorcolumn
endfunction
"}}}
function! OnWinLeave() abort"{{{
let b:colorcolumn_restore = &colorcolumn
setlocal colorcolumn=0
setlocal nocursorline
setlocal nocursorcolumn
setlocal norelativenumber
endfunction
"}}}
augroup auto_window_settings "{{{
autocmd!
autocmd WinEnter * call OnWinEnter()
autocmd WinLeave * call OnWinLeave()
augroup END
"}}} augroup auto_window_settings
" }}} auto_window_settings