diffchar.vim icon indicating copy to clipboard operation
diffchar.vim copied to clipboard

Use a new highlight group instead of using SpecialKey directly

Open Gelio opened this issue 3 years ago • 2 comments

Hey, thanks for the great plugin :+1:

I have been using it alongside https://github.com/sainnhe/gruvbox-material and I have noticed that by default the diffs become hard to read, e.g. the diff

-a() => 
+abce()

becomes

I've narrowed it down to the fact that the SpecialKey highlight is hard to read in gruvbox-material. I have opened an issue in that repo https://github.com/sainnhe/gruvbox-material/issues/85 but the author said that it's hard to fix it since there is no custom highlight group for such diffs and SpecialKey is used directly, which they do not want to change the color of.

See https://github.com/sainnhe/gruvbox-material/issues/85#issuecomment-846324992 for more information and suggestions from the theme author.

Would it be possible to create a new highlight group for the inner-line diffs and link it to SpecialKey, so that it is easier to customize the color of the highlights?

Gelio avatar May 22 '21 06:05 Gelio

Thank you for using the plugin. I reproduced here and found a regression on version 8.9. I will fix it in the next version. Meanwhile, try to modify the line 73 of your autoload/diffchar.vim like this:

@@ -70,7 +70,7 @@
 		endfor
 		call filter(dh.0, '!empty(v:val)')
 		let dh.1 = (hs == 'C' || hs == 'T') ?
-				\filter(copy(dh.0), 'v:key =~ "\\(fg\\|bg\\|sp\\)$"') : dh.0
+				\filter(copy(dh.0), 'v:key =~ "bg$"') : dh.0
 		let dh.2 = (hs == 'C') ? filter(copy(dh.1), 'v:key =~ "bg$"') :
 													\(hs == 'T') ? {} : dh.1
 		" diff_hlID() incorrectly returns (hlID() - 1) until nvim 0.4.0

rickhowe avatar May 22 '21 23:05 rickhowe

Thanks! It does look better now:

image

Gelio avatar May 23 '21 07:05 Gelio

Can I close this issue?

rickhowe avatar Jul 13 '23 01:07 rickhowe

Yes, definitely! I will close it right away. Thanks for a reminder

Gelio avatar Jul 13 '23 07:07 Gelio