feat(core): Add highlighting callback for custom inline highlighting#568
Merged
kommander merged 4 commits intoanomalyco:mainfrom Jan 24, 2026
Merged
feat(core): Add highlighting callback for custom inline highlighting#568kommander merged 4 commits intoanomalyco:mainfrom
kommander merged 4 commits intoanomalyco:mainfrom
Conversation
This was referenced Jan 21, 2026
@opentui/core
@opentui/react
@opentui/solid
@opentui/core-darwin-arm64
@opentui/core-darwin-x64
@opentui/core-linux-arm64
@opentui/core-linux-x64
@opentui/core-win32-arm64
@opentui/core-win32-x64
commit: |
Collaborator
|
Just as a tip, I'd try to avoid re-creating syntax styles in the callback itself where possible. It will not actually re-create the style or use more memory, but it has to do an FFI call with checks every time. Just something to keep in mind for repeated re-highlighting. |
Collaborator
|
Oh and I'd try to get the basics test covered to catch regressions early. |
Contributor
Author
|
Ah yes thank you, there's no reason I should be registering styles inside the callback. I was doing that in my examples. I did add some tests and please let know if I need to be more thorough. Thanks! |
Collaborator
|
Github is not picking up the core build and test job somehow 🙄 Looks fine though. I'll try again in a bit. |
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.
Adds an
onHighlightcallback toCodeRenderablethat allows post-processing of syntax highlights before they're rendered. This enables custom inline highlightingChanges
onHighlightoption toCodeRenderablethat receives tree-sitter highlights and can modify themHighlightContextinterface providing access to content, filetype, and syntaxStyleUsage
Solves
I have an open pr in opencode anomalyco/opencode#9016 to close anomalyco/opencode#2586 but my pr monkey patches
treeSitterClient.highlightOnceto get that feature working and this onHighlight callback change would allow a cleaner implementation of anomalyco/opencode#2586 and/or other custom highlight featuresExamples
I made 2 examples using this feature that I can add to the pull request as well. If it's wanted.
SearchHighlightingExample.mp4
ColorCodeExample.mp4