-
Notifications
You must be signed in to change notification settings - Fork 393
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
🚀RFC: New color/style options, diff-so-fancy/diff-highlight emulation #205
Comments
Wow, this is really cool! I have 9 places in my dotfiles that call delta, so being able to specify this somewhere would be nice. But also tbh since you fixed all the other issues, the defaults work pretty well for me (except for the theme, which I set with |
Awesome! I think it would make sense to encode at least |
I found what seems to be a bug: specifying "bold" in the box and under/overline decoration style only seems to be affecting the thickness of the lines, but not the color. |
@dandavison - that's some amazing work! I tried it and it works like a charm. I'll be keeping an eye for bugs but for now it seems great. Only thing is I had to change the default Otherwise brilliant work. Thank you! P.S. Another thing I noticed - using the config for
And doing a
Same as with |
Shouldn't the "omit" style for decorations omit only the decorations themselves, but keep the content? Or is that the actual intent? (In which case, my question is: how do I deactivate decorations alone but keep the text?) |
Thanks @waldyrious. That should be fixed now (ed7c7b8). |
@boris-petrov, thanks :)
Git's complaint about "filter must maintain a one-to-one correspondence between its input and output lines." is caused by delta adding file/hunk decorations. We can make
(I'll got through this issue later to add things to documentation.) |
Good point @waldyrious. This part of the interface definitely needs more work. Here's a proposal for how it could be changed. I'll probably make a start on implementing this:
Additional notes:
You're right, that doesn't really exist currently. In the proposal above that would be |
Everything above sounds reasonable to me! |
@gibfahn thanks!
Right. Are you thinking of the comment I made above about whether it would make sense for delta to read from For now, does it help to use a wrapper shell script containing the repeated delta options? For anyone else reading this who's not sure how to do that, what I mean is something like creating a file called #!/bin/bash
exec delta --my-option-1 value1 --my-option-2 value2 "$@" Then doing |
@waldyrious I've implemented everything proposed in the comment above. The comment has the details but e.g. commit/file/hunk-header elements now support
|
@dandavison Nice, thanks! Just tested it locally, it works well. I seem to have found a bug, though: if I pass the $ git diff | delta-dev --file-decoration-style 'box'
───────────────────────────────────────────┐
renamed: i/diff-test.txt → w/diff-test.txt │
───────────────────────────────────────────┴───────────────────────────────────
⋮ Can you take a look? (By the way, the detection of a modified file as a rename also seems like a bug) |
Thanks @waldyrious.
Could you post a diff that exhibits incorrect behavior? (We could make a new issue for this; up to you.)
That is actually long-standing delta behavior: for
For backwards-compatibility, I'll continue to support |
Decoration styles now compose, so we can do things like
|
As a Looking forward to the upcoming release incorporating all of this styling work. In my case, I am looking to primarily emulate the Great work @dandavison |
I noticed an issue with emulating diff-so-fancy mode. If the diff simply removes a blank line, you can't tell because delta removes the |
Related to my previous comment
...I would perhaps like to try adding a background to the file lines, since this doesn't seem to affect line wrapping, and would still provide a full-width visual separator (while also saving two lines per file header!). Is this the sort of thing you were talking about above, @dandavison, when you wrote the following?
|
Yes, exactly. There's a prototype of that in @da-x's branch linked in #168. So one possibility is we make background colors in EDIT: I think we would not want background colors to extend to full terminal width when a |
Thanks @mk12, good point. I think we can say that's a bug: delta should always make changes visible, even if the |
I'm very close, I hope, to releasing the next version of delta (future release won't be like this!). Here are the major changes since the last activity in this issue:
Here's a quick example of how delta can be configured now. This goes in your usual git config file (delta will look for it in all the same places as git usually does). [core]
pager = delta
[interactive]
diffFilter = delta --color-only
[delta]
features = diff-so-fancy decorations line-numbers
syntax-theme = Monokai Extended
[delta "decorations"]
commit-decoration-style = bold yellow box ul
file-style = bold 19 ul "#dddddd"
file-decoration-style = none
[delta "line-numbers"]
line-numbers-left-format = "{nm:>4}┊"
line-numbers-right-format = "{np:>4}│ " You don't have to use features: everything can go under The above corresponds to a single command line invocation like this, but we usually won't need to write these out any longer:
If anyone still has energy for helping out, I think the question right now is:
Other changes in master include
Notes
[include]
path = ~/.config/delta/delta.conf
instead of including A draft of the README for the next version is here. @waldyrious, your diff-highlight example above can now be achieved like this: [delta]
diff-highlight = true
file-style = bold yellow
file-decoration-style = 'bold yellow box' |
Amazing work @dandavison. I love the new configuration modes, and the convenience of the compatibility presets. About the latter, by the way, I'm wondering — is it intentional that e.g. To illustrate what I mean, here's the Here's And here's I think (I couldn't get the hunk header to show in bold magenta, btw... what am I doing wrong?) |
Thanks @waldyrious, extremely useful feedback. You're right: Default, no With [color "diff"]
meta = bold yellow
frag = bold magenta The full details are: there are 3 related built-in features:
That's weird, I copied your command line and couldn't reproduce it. Can you try again? |
Interesting. If I pipe the output of git's diff to delta (rather than setting delta as git's pager), the (I also tested with |
Ah, right. That occurs because (a) |
OK, thanks very much for all the help everyone. 0.2.0 is released now! From the release notes (https://github.com/dandavison/delta/releases/tag/0.2.0): The highlights are:
|
Outstanding work. I just fully transferred over to One minor point, much of the documentation states Best regards. |
@0xC0FFEE @Amorymeltzer @CSRaghunandan @Kr1ss-XD @bluz71 @boris-petrov @clnoll @da-x @elbaro @gibfahn @gpressutto5 @jc00ke @lightspeedbriefs @mk12 @natsumi @waldyrious @JNRowe
Hi everyone,
TL;DR: If you are able to run the new delta in
master
by building from source, that would be really useful and much appreciated. Your current config should just work as before without you changing anything: please let me know if it doesn't.Thanks very much for your help with delta. I'm opening this issue to describe the new options for configuring colors and styles in the unreleased version of delta in
master
. To keep the discussion in one place, I've tagged people here who have been helping with delta development and are involved in the various issues related to this topic: any feedback/bug reports/complaints etc you're able to give would be much appreciated. I hope this is OK, let me know if not and please use the Unsubscribe button on the right-hand side of the issues UI to stop notifications from this issue. The notes below will become the release notes for the next release.Although it seems like a lot of changes, no command-line options have been removed:
master
should be 100% backwards-compatible.The
master
branch has added new options for configuring foreground and background colors, and box/line etc decorations. Every stylable elementfoo
now has two options:--foo-style
and--foo-decoration-style
. Both accept a "style string". An example of a style string is'ul bold red "#420000"'
meaning "bold, red, underlined foreground (text) color with background color#420000
".So it's basically the same style/color mini-language as is used by gitconfig (and thus by diff-highlight & diff-so-fancy). There are some delta-specific extensions: for example, you use the special color name 'syntax' as a foreground color to request syntax highlighting.
This allows lots of things that weren't possible before: e.g. non-syntax highlighting text colors for code, background colors for unchanged code lines, background color for commit/file/hunk-header lines, and the ability to apply any subset of the 8 available style attributes to text: blink, bold, dim, hidden, italic, reverse, strike, ul (or underline).
Here's an example showing how to use a light theme with a dark terminal background (#153). (This is possible because we can now override the terminal's background colors in more places.)
And here's diff-so-fancy / diff-highlight emulation:1 (#177, #169, #193):
Here's the relevant section of
delta --help
:The old options such as
--minus-color
(meaning the background color) are all still available, and everything is intended to be backwards compatible, butdelta --help
describes the old options as deprecated. Here's a summary of what's changed:--minus-color
, etc--foo-style
instead--zero-style
--file-color
,--commit-color
--foo-style
instead--hunk-color
--hunk-header-style
instead--hunk-style
--hunk-header-decoration-style
--file-style
,--commit-style
Use
--foo-decoration-style
for the decoration.There's one slightly subtle technicality:
--file-style
, and--commit-style
now configure the text, whereas previously they configured the decoration surrounding the text. But, users' current configs will be using "box" and "underline" in this context to configure the decoration. So, for backwards compatibility, "box" and "underline" (or "ul") are allowed to occur here and are applied to the decoration if they are encountered.The changes described here close the following issues:
Related to but does not close yet:
Remaining questions / work needed:
To build delta from source:
You'll need to install the rust tools.
1 The styles are from the example in the diff-so-fancy README.
The text was updated successfully, but these errors were encountered: