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 scopes for cpptools colorization, to light_vs and dark_vs #75916

Closed
wants to merge 5 commits into from
Closed

Add scopes for cpptools colorization, to light_vs and dark_vs #75916

wants to merge 5 commits into from

Conversation

Colengms
Copy link
Contributor

We've added colorization to cpptools, using TextEditorDecorations. We are leveraging the existing system for theming and customization. A list of scopes we are using to retrieve color settings are here: /~https://github.com/microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/colorization.md

This PR is to add those scopes to the default VS Light and Dark themes. The scopes are specifically for C and CPP, so should not affect other languages. Scopes for the default TextMate grammar for C/CPP are limited, so very few of these will be applied if the cpptools extension is not present and enhancedColorization enabled.

I would be very interested in feedback regarding the scope names we have chosen. As there are not strict guidelines for scope naming, these are a best effort to use appropriate names. But, I would be interested in hearing from someone with more experience with TextMate scopes on whether these are the most appropriate names.

A list of all of the known issues we have encountered with attempting to do colorization this way, are here:

• VSCode: TextEditorDecoration applied to incorrect range if racing with user edit
#74094

• VSCode: TextEditorDecorators should also be rendered in minimap
#73140

• VSCode: Text selection highlight is not shown on decorations w/background colors
#75642

• VSCode: Option to not style rendered whitespace with TextEditorDecorationType
#49462

Related issues:
• VSCode: Provide an API for advanced/semantic source highlighting
#585

• VSCode: Dynamic injection grammar contributions
#53885
We are overwriting the package.json instead, which requires a reload.

• VSCode: [theming] Access theme's colors programmatically
#32813
We are loading theme files, scanning token color and textMateRule override settings, and compositing cascaded styles, ourselves.

• Language-server-protocol: Support semantic highlighting
microsoft/language-server-protocol#18

@aeschli
Copy link
Contributor

aeschli commented Jun 24, 2019

Colorization using decorators is an interesting idea.
Can you explain why this involves adding scopes to the default themes?
Note that changing any aspect of the default themes is not in our interest. As you can see from the test failures, your changes have caused changes in other languages.

@Colengms
Copy link
Contributor Author

In the process of identifying tokens semantically, we are attributing a 'scope' to them, in order for colors to be customizable using the existing support for theming and color customization. We'd like the default "VS" themes to include these new scopes/colors so C++ developers see the same colorization they see in VS. There were also a few colors that did not actually match the VS Dark and VS Light themes, and I assumed those were in error and corrected them. (Also, FYI, it's unclear to me if this is a bug in VS Code or not, but: when specifying a color for a scope of "a.cpp", it will not match a scope of "a.b.cpp", so it's necessary either to color all possible sub-scopes separately, or color just 'a', which applies to all languages)

We were attempting to do both syntactic and semantic colorization ourselves. I'm in the process of removing our own syntactic work, in factor of leveraging existing text mate colorization for syntactic, and we would only add semantic colorization to it. I will post an update shortly which removes a number of these scopes that we no longer use. I will also update failing tests, of course.

@aeschli
Copy link
Contributor

aeschli commented Jun 26, 2019

To add scopes just for cpp you would have rules like source.cpp variable. There can be plenty of variants of variable and you don't want/can't list them.
Especially you don't want to add scopes that are too grammar specific as grammars can be replaced by extensions (and also sometimes we switch our built-in grammars from one to another)

When we started our default themes many years back, they where copies of the VS default themes. But the two have went their own paths in the meantime and that's ok like that.

We came up with a concept of (a small) set of colors that we use consistently across languages and spend lot's of time making them work with all the grammars we ship (around 30).
In the process we've learned that any changes to theme is a very sensitive topic that can cause a lot of emotions.
I understand there are users that want c++ coloring exactly like in VS. What about offering them a separate theme? We have the marketplace for that.

@Colengms Colengms closed this Jun 27, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants