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

gbl should have nice syntax coloring (or optionally use GIT_PAGER or bat?) #370

Open
cjappl opened this issue Mar 18, 2024 · 6 comments
Open

Comments

@cjappl
Copy link
Collaborator

cjappl commented Mar 18, 2024

Currently if you use gbl you get a rather dull monochrome blame:

Screenshot 2024-03-18 at 2 52 36 PM

It would be nice if we could put this through a nicer pager, or add syntax highlighting somehow.

@cjappl cjappl mentioned this issue Mar 18, 2024
15 tasks
@ccoVeille
Copy link
Contributor

isn't it already possible ?

FORGIT_BLAME_PAGER='bat --color=always -l log' git forgit blame

image

FORGIT_BLAME_PAGER='bat --color=always -l gitlog' git forgit blame

image

@sandr01d
Copy link
Collaborator

isn't it already possible ?

FORGIT_BLAME_PAGER='bat --color=always -l log' git forgit blame

@ccoVeille this would color everything using the same syntax (log), but ideally we would have syntax highlighting based on the file.

bat (which we already use for gbl) supports syntax highlighting based on the file extension. We currently do not pass the file name to bat and only pipe the content of the file when using gbl. We could use the --file-name parameter to make bat use the correct syntax. I did a quick and dirty implementation to see what the results would look like. Some files look fine, e.g.

image

For others, the annotations get colored, since bat isn't aware of them.

image

This is especially bad when using --color-by-age or --color-lines since it makes the highlights in the annotations less visible IMO:

image

Would be interested what others think, but I personally would value visible highlights from --color-lines more than syntax highlighting in the context of git blame.
delta has special highlighting for git blame. This can already be used when configuring delta as pager.

@ccoVeille
Copy link
Contributor

Thanks for your reply. It's clearer.

I like the implementation you made

@carlfriedrich
Copy link
Collaborator

@sandr01d I would also value the --color-lines more than syntax highlighting of the file.

However, if delta supports git blame highlighting (which is cool, wasn't aware of that!), then we have a solution, don't we? We could add delta as a soft dependency, just like we do with bat. How about that?

Personally, I am using diff-so-fancy as a pager because I like its diff presentation more than delta's. That's personal preference, though, and I would actually like using delta for gbl if it does something useful there.

@sandr01d
Copy link
Collaborator

sandr01d commented Jun 25, 2024

I agree with you @carlfriedrich. The AUR package already has delta as an optional dependency and we also list it on our README. The only thing to look out for with delta and blame is dandavison/delta#1278, but this can be worked around with FORGIT_BLAME_GIT_OPTS="--date=iso8601" for now.

@ccoVeille
Copy link
Contributor

@carlfriedrich it's indeed a good solution.

Also, you could mention delta as a recommended dependency. And the code react to delta availability.

But it might be what you were thinking about

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

4 participants