Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise highlight logic to be simpler and obey user settings #729

Draft
wants to merge 3 commits into
base: master
from

Conversation

@jsit
Copy link

@jsit jsit commented Aug 8, 2020

I still think there's some inconsistency in this highlight logic that needs to be resolved. Here's a matrix of behaviors when different settings are set by the user:

master

set_sign_bg 0 set_sign_bg 1
fg unset, bg unset sets fg, sets bg sets fg, sets bg
fg set, bg unset does nothing sets bg
fg set, bg set does nothing sets bg
fg unset, bg set sets bg sets bg

pr 729

set_sign_bg 0 set_sign_bg 1
fg unset, bg unset sets fg sets fg, sets bg
fg set, bg unset does nothing sets bg
fg set, bg set does nothing sets bg
fg unset, bg set does nothing sets bg

In master, there are two scenarios where set_sign_bg is 0 and the background still gets set by the plugin.

Is this plugin trying to do too much for the user? Should it maybe just do:

execute "highlight default GitGutter".type." guifg=".guifg." ctermfg=".ctermfg." guibg=".guibg." ctermbg=".ctermbg

and if the user is setting colors themselves, then they can just take care of it on their own? Otherwise, I feel like this is the behavior we should maybe be seeing:

fg unset fg set
bg unset sets fg, sets bg sets bg
bg set sets fg does nothing
@jsit jsit marked this pull request as draft Aug 9, 2020
@airblade
Copy link
Owner

@airblade airblade commented Sep 7, 2020

Sorry for the delay, I've been away.

master table: I think the final row's results are wrong: the code will set both the foreground and the background regardless of g:gitgutter_set_sign_backgrounds.

pr 729 table: as far as I can tell your PR doesn't use the g:gitgutter_set_sign_backgrounds variable, so I don't understand where the results in the "set_sign_bg 1" column come from. I would think the behaviour is always as per the "set_sign_bg 0" column.

In master, there are two scenarios where set_sign_bg is 0 and the background still gets set by the plugin.

You are right and when you put it like this, it sounds confusing ;) Two assumptions I never wrote down were:

  • if someone has bothered to define GitGutter* highlight groups, they will have set the foreground colours;
  • g:gitgutter_set_sign_backgrounds only applies to existing GitGutter* highlight groups.

Is this plugin trying to do too much for the user?
...if the user is setting colors themselves, then they can just take care of it on their own?

I think this is subjective. It certainly isn't necessary for the plugin to adjust the signs' background colours automatically and it makes the code more complicated. However, when changing colorschemes, I think it is helpful for the plugin to adjust the signs' backgrounds automatically to match the new sign column colour (admittedly only necessary if the user has defined GitGutter* highlight groups, not the colourscheme).

Having said all that, your final table looks ideal to me and I think we should make the plugin do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.