summaryrefslogtreecommitdiff
path: root/.vim/feat/term_scroll.vim
diff options
context:
space:
mode:
Diffstat (limited to '.vim/feat/term_scroll.vim')
-rw-r--r--.vim/feat/term_scroll.vim19
1 files changed, 19 insertions, 0 deletions
diff --git a/.vim/feat/term_scroll.vim b/.vim/feat/term_scroll.vim
new file mode 100644
index 0000000..d01fe4c
--- /dev/null
+++ b/.vim/feat/term_scroll.vim
@@ -0,0 +1,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