Repository navigation
feat(tui): chroma syntax highlighting for diff and content preview - #868
Merged
Merged
Conversation
Add language-aware syntax highlighting using chroma (already a transitive dependency via glamour) for diff content and file content previews in the card-based tool-call formatter, keyed off file extension with a plain fallback. - Add WithChromaStyle fluent setter to diffview.DiffView - Add chromaStyle() helper on DiffRenderer, deriving github/github-dark from the active theme's brightness - Wire chroma into buildDiffView() for diff syntax highlighting - Wire chroma into renderContentPreview() for file content previews - Three unit tests covering known language, unknown extension, and nil style (no crash) scenarios
Contributor
|
🎉 This PR is included in version 0.143.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add language-aware syntax highlighting using chroma (already a transitive dependency via glamour) for diff content and file content previews in the card-based tool-call formatter, keyed off file extension with a plain fallback.
Changes
diffview/diffview.go— AddWithChromaStylefluent setter onDiffView. Nil/no-call preserves exact current behavior. Clears the syntax cache on set.diff_renderer.go— Add privatechromaStyle()method derivinggithub(light) orgithub-darkfrom the active theme's brightness. Wire it intobuildDiffView()andrenderContentPreview()(which now takes afilePathparameter for lexer selection).diff_renderer_test.go— Three new tests: known language (.go), unknown extension (.xyzabc), and nil style provider (no crash).Key Design Decisions
chromaStyle == nilinsidehighlightCode()Highlight()withlineNumbers=falsefor content previewsHighlighthandles tab expansion, normalization, tokenisationcontentPreviewLimitcap applied after highlightingTesting
task precommit:run— all hooks passTestDiffRenderer_*tests passTestDiffRenderer_SyntaxHighlight_*tests passCloses #866