Closed washtubs closed 11 months ago
+1 - I'm also annoyed by this as the syntax is often not helpful.
Hey @washtubs, @deanhouseholder. I agree that it should let you do this! Are you sure it isn't working already though? A quick test:
git show | delta --no-gitconfig
git show | delta --no-gitconfig --hunk-header-style line-number
I'm also able to reproduce that using gitconfig
[delta]
hunk-header-style = line-number
Oh I don't mean the coloring, I was thinking in your second example, it should just be a box with "21:". That was my understanding of what syntax referred to unless I'm missing something?
Ah, right! No, syntax
says "I want syntax highlighting colors on this piece of text (assuming it can be interpreted as code in some programming language)"
We don't currently have a way to say "please hide the hunk header code fragment entirely".
However, you could set its foreground color to be equal to your background :)
E.g. --hunk-header-style 'line-number #000000'
if you're on a black background.
I have a white background currently:
git show | delta --no-gitconfig --hunk-header-style 'line-number #FFFFFF'
Of course, that leaves a large box... you could play with hunk-header-decoration-style
:
--hunk-header-style 'line-number #FFFFFF' --hunk-header-decoration-style ul
Does anything along those lines achieve what you're looking for, at least as a workaround?
It is a workaround for sure! I'm not too keen on the invisible text method as it's still gonna be there and still be selectable, not to mention I'm not confident I would be able to programmatically pick the right background color depending on the environment.
I did experiment with another setting, because I don't necessarily even need the line number, I tried --hunk-header-style=omit
. This would have done it for me, however the problem with this one is because the boundary between hunks is just a blank line, there is no way to distinguish a boundary between two hunks vs a blank line within a hunk.
For example this is with a hunk header.
This is without a hunk header. Note that after - checkout
there's no way for me to tell if that is the end of a hunk or just a continuation.
In case it helps, this is exactly the problem I'm having and hoping for a solution to. @washtubs nailed it.
Adding another "+1" to the list here, I struggled fighting the settings to try and get things working but to no avail.
Another thing I noticed with hunk-header
settings is only hunk-header-style
is outputting when asking to show the config (filed here: https://github.com/dandavison/delta/issues/1458)
I ran into this today and decided to work on a patch to make it configurable. I have not filed a PR yet but you can view/try the branch at my fork (diff view).
My one hesitation is that while it technically won't change delta's default behavior, existing "themes" will drop the code fragment unless they are updated. This could be worked around by e.g. using no-code-fragment
and inverting its logic, but I would like to hear what @dandavison thinks first if he's got a minute.
The style 'omit' can be used to remove the hunk header section from the output.
The attribute 'omit' is supported by commit-style, file-style, and hunk-header-style, meaning to remove the element entirely from the output.
So perhaps we should just call this omit-code-fragment
? It's not beautiful, I agree.
Internally, I'd be happy for your implementation to use the non-inverted names that you are currently, i.e. HunkHeaderIncludeCodeFragment
Hi @zmc, I think your design is how it should have been initially. However, I'm not sure it's worth the breaking change today
Agreed - I don't like the idea of breaking anyone's existing configuration.
So perhaps we should just call this
omit-code-fragment
? It's not beautiful, I agree.Internally, I'd be happy for your implementation to use the non-inverted names that you are currently, i.e.
HunkHeaderIncludeCodeFragment
Ended up doing exactly this :)
The help menu seems to suggest that I can adjust this
However if I use
--hunk-header-style "line-number"
without specifyingsyntax
I still see the syntax. I would think since I didn't specify syntax it wouldn't show that. I understand changing this might be considered "breaking". Is there any other way to keep the hunk header but not show the syntax? Maybe a newnosyntax
option? Personally I like having the hunk headers clearly visible, but I find the syntax to just be distracting for the files I'm comparing.