Allow telling diff renderers whether the terminal is dark or light - #6063
Merged
Merged
Conversation
stefanhaller
added this pull request to stack #6064
September 26, 2026 17:20
stefanhaller
force-pushed
the
diff-renderer-color-scheme
branch
from
September 27, 2026 06:09
dafcc12 to
1f62f98
Compare
The getters for the stdin filter and the external diff command each take the values they fill in as parameters of their own, and each builds the placeholders for them. The next commit checks the commands when the config is loaded, and for that it needs to resolve a command whatever its kind. A value that both kinds can use comes after that. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The command of a diff renderer can refer to values like the width it
renders at, as {{width}}. They are filled in by plain replacement, so a
command can't choose between options depending on them. The next commit
adds a value that needs this: whether the terminal is dark or light.
delta takes --dark or --light, but for other renderers the choice has to
be spelled out differently, for example as the name of a syntax theme.
Resolve the command as a Go template instead. The values become its
variables, so that {{if gt .width 160}} --side-by-side{{end}} works too.
To keep the existing commands working, a variable can still be written
without the leading dot.
A mistake in a template, such as a misspelled variable, now makes
resolving the command fail, instead of leaving the placeholder in it.
Check the commands when the config is loaded, by resolving each of them
with made-up values, so that the mistake shows up as an invalid config.
This also rejects a variable that the kind of renderer doesn't have,
such as {{columnWidth}} in the command of an external diff; until now,
it reached the renderer as it was.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The next commit needs to render the diff again when the terminal switches between dark and light, with the same care not to replace whatever else the main view might show. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Renderers like delta and difftastic pick their colors for either a dark
or a light background, and they can't find out which one the terminal
has. Lazygit runs them with TERM=dumb, in a pty that doesn't answer
their queries. So the colors come from the config, and when the
terminal switches between dark and light, the diff keeps the ones it
has.
Add {{colorScheme}} to the commands of diff renderers. It is 'dark' or
'light', going by gui.colorScheme, or by the terminal if that is
'auto'. It can be passed to delta as --{{colorScheme}} and to
difftastic as --background={{colorScheme}}; other renderers can choose
between options with a template expression. When the terminal switches
between dark and light, render the diff again.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
stefanhaller
force-pushed
the
diff-renderer-color-scheme
branch
from
September 27, 2026 06:09
1f62f98 to
d38248d
Compare
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.
Renderers like delta and difftastic pick their colors for either a dark or a light background, and they can't find out which one the terminal has, because lazygit runs them with TERM=dumb, and in a pty that doesn't answer their queries.
Add
{{colorScheme}}to the commands of diff renderers. It is 'dark' or 'light', based on what the terminal reports (which can be overridden bygui.colorSchemeif the terminal doesn't support the query). It can be passed to delta as--{{colorScheme}}and to difftastic as--background={{colorScheme}}; other renderers can choose between options with a template expression.