Hey @dandavison! Thanks for making such an absolutely indispensable tool like delta!
Feature Request
delta is great for diffs (and soon blame?), but I have a suggestion* for an additional mode that might be useful to others -- the ability to syntax-highlight git grep output!
Why git grep?
I mention git grep specifically as opposed to grep / ack / ag/ pt / rg because of two extremely powerful features of git grep that the competition lack.
Boolean Expressions
First, let's look at its ability to have complex nested boolean expressions like --and --not and grouping which make git grep very powerful. For example, let's say we wanted to search for certain kmalloc invocations that also DO NOT have GFP_KERNEL or GFP_ATOMIC. Yes, you could do e.g. `grep kmalloc | grep -vE 'GFP_(KERNEL|ATOMIC)', but for the sake of demonstration...

Full Function Context
More importantly, it also has the ability to show the entire function in which a match resides with --function-context (-W).
Note the =, :, and - markers after the line numbers, indicating lines-with-match, the function name, and context lines.
(Large screenshot warning)

Example Output
I've jury rigged a (very ugly zsh-based) solution** that gives me effectively what I'm asking for in this feature request, but it would be better if it were directly integrated into delta (and others would also be able to benefit from this). Effectively, I parse the markers and shells out to bat to show and highlight the correct lines.

Added Bonus Functionality!
While git grep is very powerful, if you look at the second screenshot above, you'll note that there is only ONE line matching the query -- line 1482. However, every instance of sizeof and ; etc that are in the query are also highlighted.
I'm not sure why Git does this, but by parsing out the symbols at the beginning of the line, delta could be even BETTER by not highlighting these partial-matches-in-the-same-function. Note that my example output (third screenshot) does not replicate this undesirable behavior.
Additional Niceties
For many of the default themes, the "highlight" color for bat is not ideal. I work around this by using a custom-compiled theme based off solarized-dark, to effectively achieve the same highlight color as delta uses for added (green) lines.
Hopefully this isn't an issue for delta, because you can just use the internal setting for whatever the "line added" theme color is.
Closing Remarks & Comments
Let me know what you think of the idea!
* This suggestion might belong better in the bat project, but I feel like it fits with delta better due to the useful functionality is based on Git (i.e., git grep -W and git log -p -W), delta having good support and features for lots of Git things with highlighting, and because bat is just a highlighter for languages and should probably remain pure that way.
** _Technically it's a wrapper around bat, i.e. it parses the --function-context markers. I showed the command-line that it generates in the screenshot above, for an example.
Hey @dandavison! Thanks for making such an absolutely indispensable tool like
delta!Feature Request
deltais great for diffs (and soonblame?), but I have a suggestion* for an additional mode that might be useful to others -- the ability to syntax-highlightgit grepoutput!Why
git grep?I mention
git grepspecifically as opposed togrep/ack/ag/pt/rgbecause of two extremely powerful features ofgit grepthat the competition lack.Boolean Expressions
First, let's look at its ability to have complex nested boolean expressions like
--and--notand grouping which makegit grepvery powerful. For example, let's say we wanted to search for certainkmallocinvocations that also DO NOT haveGFP_KERNELorGFP_ATOMIC. Yes, you could do e.g. `grep kmalloc | grep -vE 'GFP_(KERNEL|ATOMIC)', but for the sake of demonstration...Full Function Context
More importantly, it also has the ability to show the entire function in which a match resides with
--function-context(-W).Note the
=,:, and-markers after the line numbers, indicating lines-with-match, the function name, and context lines.(Large screenshot warning)
Example Output
I've jury rigged a (very ugly zsh-based) solution** that gives me effectively what I'm asking for in this feature request, but it would be better if it were directly integrated into
delta(and others would also be able to benefit from this). Effectively, I parse the markers and shells out tobatto show and highlight the correct lines.Added Bonus Functionality!
While
git grepis very powerful, if you look at the second screenshot above, you'll note that there is only ONE line matching the query -- line 1482. However, every instance ofsizeofand;etc that are in the query are also highlighted.I'm not sure why Git does this, but by parsing out the symbols at the beginning of the line,
deltacould be even BETTER by not highlighting these partial-matches-in-the-same-function. Note that my example output (third screenshot) does not replicate this undesirable behavior.Additional Niceties
For many of the default themes, the "highlight" color for
batis not ideal. I work around this by using a custom-compiled theme based off solarized-dark, to effectively achieve the same highlight color asdeltauses for added (green) lines.Hopefully this isn't an issue for
delta, because you can just use the internal setting for whatever the "line added" theme color is.Closing Remarks & Comments
Let me know what you think of the idea!