summaryrefslogtreecommitdiff
path: root/.vim/miniplugins/spell_check_mode.vim
blob: cfdd46a039167a4d7e1dfeb129c5c315dafe70ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
" When you press F6 it will toggle a "spell check mode", 
" spell is activated and the colour scheme is changed
nmap <F6> :call SpellCheckModeToggle()<CR>

function! SpellCheckModeToggle()
	if g:colors_name == 'gruvbox'
		set spell
		colorscheme darkblue
	else
		set nospell
		colorscheme gruvbox
	endif
endfunction

" Scrolling (shows history) in terminal (except in lazygit)
" Scroll up to activate it, and press a 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 <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