sad*_*v30 5 eclipse syntax visual-studio-code
在 C/C++ 中,在 Eclipse 编辑器中,您可以在更多语言级别设置颜色:例如,函数参数,局部变量可以具有不同的颜色。可以更改静态和全局变量颜色。可以配置宏和宏引用。
如何在 Visual Studio Code 中做到这一点?我不确定 text mate tmLanguage 是否可以实现这一点。我找不到任何文档。
[see further below for v1.45 changes]
You are not limited to a theme's supplied semantic token highlighting. You can choose the color and fontstyle yourself for supported language-semantic tokens by doing this:
It's also possible to define semantic theming rules in the user settings:
Run Code Online (Sandbox Code Playgroud)"editor.tokenColorCustomizationsExperimental": { "property.readonly": { "foreground": "#35166d" }, "*.defaultLibrary": { "fontStyle": "underline" } }
And see especially https://github.com/microsoft/vscode/wiki/Semantic-Highlighting-Overview#how-can-i-find-out-what-semantic-tokens-are-available-and-how-they-are-themed for how to discover the semantic tokens. For example:
If there is no semantic token type listed, that language service does not yet support them. But undoubtedly, when they do you will want to modify some of their color and fontstyle choices.
vscode 1.45 will rename editor.tokenColorCustomizationsExperimental to editor.semanticTokenColorCustomizations
See https://github.com/microsoft/vscode/issues/96267
This syntax works for me in the Insiders' Build April, 2020:
"editor.semanticTokenColorCustomizations": {
"enabled": true,
"rules": {
"enumMember": "#ff0000"
},
"[Default Dark+]": {
"enabled": true,
"rules": {
"variable.readonly": "#ff00ff"
},
}
},
Run Code Online (Sandbox Code Playgroud)
Semantic coloring is available for TypeScript and JavaScript, with support for Java, C++ in the works. It is enabled by default for built-in themes and being adopted by theme extensions.
The
editor.semanticTokenColorCustomizationsallows users to overrule the theme settings and to customize the theming.Example that adds semantic styling to all themes: ```
Run Code Online (Sandbox Code Playgroud)"editor.semanticTokenColorCustomizations": { "enabled": true, "rules": { "property.readonly": { "foreground": "#35166d" }, "*.defaultLibrary": { "bold": true } } }Run Code Online (Sandbox Code Playgroud)
The setting above colors all constants with
#35166dand all occurrences of symbols from a default library (e.g.Math,setTimeout) bold.
Example that adds semantic styling to the Dark+ themes: ```
Run Code Online (Sandbox Code Playgroud)"editor.semanticTokenColorCustomizations": { "[Default Dark+]": { "enabled": true, "rules": { "parameter": { "underline": true }, "*.declaration": { "bold": true } } } }Run Code Online (Sandbox Code Playgroud)The setting above underlines all parameters in the Dark + theme and makes all symbol declarations bold. Theming for semantic tokens is explained in more details in the [Semantic Highlighting Guide](/api/language-extensions/semantic-highlight-guide#theming).
Oddly, in my testing even with the enabled: true in the above "editor.semanticTokenColorCustomizations" you still need this setting enabled:
"editor.semanticHighlighting.enabled": true
Run Code Online (Sandbox Code Playgroud)
but that is the default.
您可以在此处阅读有关范围和语法突出显示颜色的更多信息。
去年Microsoft/vscode 问题 27894中对此进行了记录/请求,由PR 29393实施。请参阅VSCode 1.15 中的
“用户可定义语法突出显示颜色”,修改颜色主题。
请注意,VSCode 1.42 确实包含TypeScript 和 JavaScript 的语义突出显示
对 TypeScript 和 JavaScript 的语义突出显示支持正在开发中,默认情况下尚未启用。
但您可以通过添加以下设置来尝试:Run Code Online (Sandbox Code Playgroud)"editor.semanticHighlighting.enabled": true启用后,您将看到一些标识符获得新的颜色和样式,并且现在根据其解析的类型突出显示。
语法 (TextMate) 荧光笔将许多标记分类为变量。这些现在变成了命名空间、类、参数等等。您可以在导入部分看到这一点,现在每个导入的符号都用符号的类型着色:
您可以使用该
Developer: Inspect Editor Tokens and Scopes命令检查为每个位置计算的语义和语法标记。
将其editor.semanticHighlighting.enabled与修订后的 2020 年 4 月 1.45 版相结合editor.semanticTokenColorCustomizations(请参阅Mark的回答),您可以定义所需的语法突出显示。
| 归档时间: |
|
| 查看次数: |
5367 次 |
| 最近记录: |