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

🐛 Line numbers style not taking effect with --side-by-side #251

Closed
amanjitsk opened this issue Jul 13, 2020 · 6 comments
Closed

🐛 Line numbers style not taking effect with --side-by-side #251

amanjitsk opened this issue Jul 13, 2020 · 6 comments

Comments

@amanjitsk
Copy link

amanjitsk commented Jul 13, 2020

Hi, I don't see the line number style taking effect with the new --side-by-side option.
For example, I am getting this
image
but I am expecting this
image
My delta config is as follow:

[core]
  pager = delta --side-by-side --syntax-theme=Nord
  ; pager = delta --syntax-theme=ansi-dark
  ; pager = delta --syntax-theme=ansi-light
[delta]
  ; features = defaults unobtrusive-line-numbers decorations light
  features = defaults unobtrusive-line-numbers decorations dark
[delta "defaults"]
  navigate = true
  paging = always
  whitespace-error-style = 22 reverse
[delta "unobtrusive-line-numbers"]
    line-numbers = true
    line-numbers-minus-style = red
    line-numbers-plus-style = green
    line-numbers-left-format = "{nm:>4}┊"
    line-numbers-right-format = "{np:>4}┊"
    line-numbers-left-style = red
    line-numbers-right-style = green
[delta "decorations"]
    commit-style = yellow
    commit-decoration-style = yellow box ul
    file-style = bold cyan ul
    file-decoration-style = none
    hunk-header-style = bold blue
    hunk-header-decoration-style = blue box
[delta "dark"]
    line-numbers-zero-style = "#75829c"
    minus-style = syntax "#5A4646" 
    minus-emph-style = black red
    plus-style = syntax "#415541"
    plus-emph-style = black green
[delta "light"]
    line-numbers-zero-style = "#AAAAAA"
    minus-style = syntax "#FEEDEF" 
    plus-style = syntax "#E4FDEB"
@amanjitsk amanjitsk reopened this Jul 13, 2020
@amanjitsk amanjitsk changed the title 🐛 🐛 Line numbers style not taking effect with --side-by-side Jul 13, 2020
@dandavison
Copy link
Owner

dandavison commented Jul 14, 2020

Hi @amanjitsk, nice delta config! I think moving side-by-side to the left-hand end of the features list gets you what you want:

[core]
    pager = delta --syntax-theme=Nord
[delta]
    features = side-by-side defaults unobtrusive-line-numbers decorations dark
...

If you want to know the details: what was going wrong with your version was this:

  • side-by-side is a "builtin-feature" and includes the line-numbers built-in feature.
  • The line-numbers built-in feature has its own default values for line numbers styles etc
  • So delta has to have some rules saying how to take in all the features mentioned as command-line flags (e.g. --side-by-side) and in feature lists, even taking into account that features are allowed to reference other features... So there's actually a tree of features with values at each node, that may conflict.

So basically in your original version, --side-by-side as a command-line flag was taking precedence over the features list, whereas you wanted the opposite.

With a complex config like yours, I'd recommend putting everything in the features list, and not using any flags like --side-by-side. The rule then is that (a) features later in the list have priority over features earlier in the list, and (b) the linear ordering is a pre-order traversal, starting from the right end of the list.

If you think it's a bit OTT to define rules for resolution of config values involving tree traversal...I agree! So I don't expect users to want to know that. I'd just say that "delta does its best to make sense of all the linked features" and if it gets it wrong then the thing to do is to list out individual config values explicitly (and open an issue if it's not easy to get delta to do what you want)

@dandavison
Copy link
Owner

The full rules are given in a code comment but like I said, it is a bit OTT and I don't expect many people to care or want to know about it!

@amanjitsk
Copy link
Author

amanjitsk commented Jul 14, 2020

Hi @dandavison , Thanks for the detailed feedback. That did the trick!
Thanks for helping me understand the config as well - I was just trying to put together somewhat of a readable dark scheme.
On the same note, another minor question: is it also possible to specify the syntax-theme as a config parameter as opposed to explicitly specifying it as a command line argument, as I have done above ? I know of the BAT_THEME environment variable, just wondering if there is a config alternative to that as well.
Thanks for the awesome tool btw! I had been using kitty's diff but it doesn't offer as much flexibility in terms of customization (specifying foreground color of {plus, minus}-{emph}-style helps the legibility quite a lot in dark schemes) and usage (ex. for over ssh, in tmux etc.). I think I finally have something that rivals that tool now!
Thanks,
Amanjit

@dandavison
Copy link
Owner

Hey @amanjitsk,

is it also possible to specify the syntax-theme as a config parameter as opposed to explicitly specifying it as a command line argument, as I have done above ?

Yes, absolutely: all1 command line flags can be used as git config entries, just strip the -- prefix:

[delta]
    syntax-theme = Nord

1 All the ones that make sense anyway. So not e.g. --show-syntax-themes etc.

@amanjitsk
Copy link
Author

Great, I was adding it to the "defaults" feature group before.
Thank you!

@dandavison
Copy link
Owner

Thanks, I think that's a bug: #252

I had been using kitty's diff

Oh, you know, I had not seen that. It looks very impressive -- I shall have to take a closer look!

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

No branches or pull requests

2 participants