yay icon indicating copy to clipboard operation
yay copied to clipboard

Use bat for Syntax-Highlighted PKGBUILD Review

Open niekdomi opened this issue 1 year ago • 5 comments

Is your feature request related to a problem? Please describe.

I'm always frustrated when reviewing PKGBUILD scripts within yay, as the default method lacks syntax highlighting and proper formatting. This makes it harder to quickly understand and analyze the script's contents.

Describe the solution you'd like

It would be a great enhancement if yay could leverage the bat tool to display PKGBUILD scripts. bat provides syntax highlighting and a more visually appealing output, which would improve readability and make it easier to review scripts for potential issues.

niekdomi avatar Dec 02 '24 21:12 niekdomi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 25 '25 01:04 stale[bot]

go away stale bot

niekdomi avatar Apr 25 '25 08:04 niekdomi

yay uses the git diff command for diffs. Integrating bat seems a bit harder as output would have to be piped (twice, probably to less after). I think this could probably be done by creating a script that you set as your pager tool.

For something out of the box, I'm a big fan of https://github.com/dandavison/delta which you can then set as ~/.gitconfig:

[core]
    pager = delta

[interactive]
    diffFilter = delta --color-only

[delta]
    navigate = true  # use n and N to move between diff sections
    dark = true      # or light = true, or omit for auto-detection

[merge]
    conflictstyle = zdiff3 

Jguer avatar Apr 25 '25 09:04 Jguer

Thanks for the answer, I will check this out. The idea of using bat came up, because paru provides this feature

Here's how it's done in paru if this helps: https://github.com/Morganamilo/paru/blob/55efaabda3567908c3875cea0dcd3f47847896b3/src/download.rs#L590

niekdomi avatar Apr 25 '25 20:04 niekdomi

Now this would be amazing, following to see how it goes. It's possible to generate a separate pager-stream output for yay, and that would allow the use of pager in EVERYTHING that yay does, if we rewrite how the existing stdout paging works by having it reference a single output command which we then wrap all the streams in, but I'm not sure how large a refactor that would be, given that would be a lot, right? And given how horrendous I am with Golang, as a C/C++ dev, I'm utterly lost on how to start something like this on yay hahah.

ninetailedtori avatar Nov 18 '25 21:11 ninetailedtori