-
Notifications
You must be signed in to change notification settings - Fork 44
Add new region flag for dimmed foreground #6858
Description
Problem description
This is a feature request that was already briefly discussed in #817 (comment), but I think it deserves its own issue so that it doesn't get buried in that thread.
It would be great to add a new region flag for the View.add_regions API to enable syntax highlighting with a dimmed foreground color.
The use case I have in mind for this are certain diagnostics in LSP with a special DiagnosticTag.Unnecessary property, which is utilized for unused parameters in function definitions and unused variables. Many language servers support this kind of diagnostics. These diagnostics might also be used for unreachable code blocks spanning multiple lines, but I haven't yet seen that in practice.
Preferred solution
class RegionFlags(enum.IntFlag):
# [...]
DRAW_STIPPLED_UNDERLINE = 1024
""" Draw a stippled underline below the regions. """
DRAW_SQUIGGLY_UNDERLINE = 2048
""" Draw a squiggly underline below the regions. """
+ DRAW_DIMMED = 4096
+ """ Draw the regions with a dimmed foreground color. """This should look exactly like the way control characters are already drawn, for example the <NBSP> in the following screenshot:
(I used a custom syntax definition for this example, which applies the listed scopes to the entire line.)
Notably, if a given region spans multiple scopes with different colors, the text in the region should keep its respective colors, just with a dimmed opacity. Text which is bold or italic should keep its font style.
Alternatives
none
Additional Information
One aspect to think about is what should happen if the given region starts or ends in the middle of a token used for syntax highlighting. This particular case should never happen for the LSP diagnostics mentioned above, so I imagine that it wouldn't be any problem to extend the dimmed highlighting to the start and end of syntax tokens, if that makes the implementation easier or more efficient.