Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add token/symbol for inactive code #1938

Open
RobbyCBennett opened this issue May 20, 2024 · 2 comments
Open

Add token/symbol for inactive code #1938

RobbyCBennett opened this issue May 20, 2024 · 2 comments
Labels
feature-request Request for new features or functionality semantic tokens
Milestone

Comments

@RobbyCBennett
Copy link

RobbyCBennett commented May 20, 2024

Currently, extensions have an odd way of dimming or coloring inactive code. They add non-standard a CSS class and the class dims the code. The opacity and colors are configured in the extension settings instead of in the standard place for colors in VS Code: tokenColorCustomizations: textMateRules.

// Here's what this may look like in VS Code if the user wants to configure it.
"editor.tokenColorCustomizations": {
	"textMateRules": [
		{
			"scope": "inactive",
			"settings": {
				"opacity": 0.5
			}
		}
	]
},

Here are some example of how this works already.

@HighCommander4
Copy link

HighCommander4 commented Jul 2, 2024

In clangd, we initially implemented highlighting of inactive code as a custom semantic token type, but we found this approach to be limiting in a couple of ways:

  1. It did not allow for whole-line styling of the inactive region, such as a greyed-out background color (example rendering below).
  2. It stomped on foreground colors provided by the client-side coloring engine in the inactive region. (At least for semantic tokens, "editor.semanticTokenColorCustomizations" did not allow specifying a style like "opacity" which combines with foreground colors.)

We ended up using a custom protocol extension for the server to tell the client about inactive code regions. A standard version would definitely be nice (but I'm not sure that semantic tokens are the best thing to build on).

vscode-clangd-inactive

@DanTup
Copy link
Contributor

DanTup commented Sep 4, 2024

Dart uses a Diagnostic with the DiagnosticTag.Unnecessary tag to grey the text out:

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnosticTag

I don't know if you can do this without a visible diagnostic though (in VS Code you might be able to use the "Hint" diagnostic which I think creates a much smaller squiggle, but I'm not sure if you can avoid it entirely).

@dbaeumer dbaeumer added feature-request Request for new features or functionality semantic tokens labels Sep 5, 2024
@dbaeumer dbaeumer added this to the Backlog milestone Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality semantic tokens
Projects
None yet
Development

No branches or pull requests

4 participants