summaryrefslogtreecommitdiff
path: root/.vim/feat/term_scroll.vim
blob: d01fe4c6b518604561fe66ccb787b4a21f46e633 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
" Scrolling (shows history) in terminal (except in lazygit)
" Scroll up to activate it, and press right mouse button to deactivate it
" Slightly modified version of: https://github.com/vim/vim/issues/2490#issuecomment-393973253
tmap <silent> <ScrollWheelUp> <c-w>:call EnterNormalMode()<CR>

function! ExitNormalMode()
	unmap <buffer> <silent> <RightMouse>
	call feedkeys("a")
endfunction

function! EnterNormalMode()
	if @% == '!lazygit'
		tunmap <buffer> <silent> <ScrollWheelUp>
	elseif &buftype == 'terminal' && mode('') == 't'
		call feedkeys("\<c-w>N")
		call feedkeys("\<c-y>")
		map <buffer> <silent> <RightMouse> :call ExitNormalMode()<CR>
	endif
endfunction