Closed OJarrisonn closed 1 month ago
'Now this feature is ready for merge. Just some more changes:
diff-so-fancy
patch rendererpatch_renderer
to choose which renderer to use: bat
, delta
, diff-so-fancy
or default
(no rendering)Hey @OJarrisonn, thank you really, really (really!) much for the marvelous (and I don't say it lightly) work!
As I talked with you offline, I've made a handful of changes to this PR, almost all of them "bureaucratic" in the sense that they pertain to commit order/atomicity/descriptions. Besides dropping the last commit about formatting (since I've applied formatting commit by commit), I think all of the adaptations I've done are described in each commit Maintainer edits
section.
In any case, thanks for the wait and the great implementation! Change merged into the unstable branch :+1:
In this draft PR i've introduced two options of prerenderers for patches:
bat
anddelta
.Both are external tools,
bat
is a moderncat
implementation, whiledelta
is adiff
rewrite (both written in Rust, not a coincidence). They provide some cool syntax highlight ans some other layout stuff that improves the experience of reading long patch files.In order to achieve this, i've done 2 major changes in patch-hub. The changes are:
ratatui
to0.28.1
ansi-to-tui
crate (this allows ratatui to render colored text from commands output)The next step is to add a config option to customize the renderers. But here comes a design decision that is really important: how customizable shall the renderers be?
Currently i have hardcoded both bat and delta rendering just for testing the feature. I could hardcode some more (say
diff-so-fancy
) and let the user choose from one of our curated options. But we could also let the user fully customize the renderer by providing the rendering command.The first option is my favorite since
patch-hub
is a productivity tool that isn't meant to be fully customizable, so providing some different predefined options for preview is probably best. Also let the user add a couple extra flags would be interesting (delta has a--diff-so-fancy
flag to change the layout a bit, bat has a--language
flag that support custom syntax highlighting using a user defined syntax).The second option require full documentation on how to create a good rendering command, which flags/modes would be nice, etc.
I'm leaning hard towards the first option but i want some feedback.
Example
Here is some example of what it currently looks like
Bat
Some pretty colors to help visualization of the diff syntax
Delta
More advanced syntax highlight and layout (some hardcore users might dislike)