aboutsummaryrefslogtreecommitdiffstats
path: root/bundle/diff-corrections/autoload/diff_corrections.vim
blob: 620c1b0a24350b730e92ecb7e6d4d55e0fcbf52c (plain)
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
34
35
let s:old_cursorline = &cursorline

function! diff_corrections#Run()
	if &diff
		if exists('g:colors_name') && g:colors_name ==# 'twilight256'
			highlight Comment ctermfg=7
		endif

		set nocursorline
	else
		if exists('g:colors_name') && g:colors_name ==# 'twilight256'
			execute 'highlight ' . s:old_highlight_comment
		endif

		let &cursorline = s:old_cursorline
	endif
endfunction


function! s:SaveCommentColor()
	redir => old_highlight
	silent highlight Comment
	redir END

	let parts = split(old_highlight, ' ')
	call filter(parts, {_idx, val -> val !=? "" && val !=? "xxx"})

	let restore = join(parts, ' ')

	" Remove ^@ character from the beginning that messes up the `execute` call
	return restore[1:]
endfunction


let s:old_highlight_comment = s:SaveCommentColor()