[英]Weird C# (Unity) syntax coloring
I want to achieve two things with my syntax highlighting我想通过语法高亮实现两件事
First (very important): fields in one color, arguments in other首先(非常重要):一种颜色的字段,其他颜色的 arguments
Second (not so much important): fields of fields in a different color as well第二(不太重要):不同颜色的字段字段
I do realize the second need might be impossible to achieve in VSCode, but I'm pretty sure the first one should be by default, yet it behaves very strangely in my case:我确实意识到在 VSCode 中可能无法实现第二个需求,但我很确定第一个需求应该是默认的,但在我的情况下它的行为非常奇怪:
You can see a couple of things - not only usage of argument and field is in the same color, but also field declaration is completely different than its usage's color, which is all over the place.你可以看到一些东西——不仅参数和字段的用法是相同的颜色,而且字段声明与其用法的颜色完全不同,这是无处不在的。 You can see that if variable's name matches its class name, it has the same color as the class which is ridiculous (cause it's seems like a static class now). You can see that if variable's name matches its class name, it has the same color as the class which is ridiculous (cause it's seems like a static class now).
Is there any way to have fields' declerations and its usages in one color, and arguments in other?有没有办法让字段的声明及其用法在一种颜色中,而 arguments 在另一种颜色中?
I should probably mention that semantic highlighting seems to not work - nothing changes, no matter if I turn it on true or false, restart the window or vscode altogether, nothing).我可能应该提到语义突出显示似乎不起作用 - 没有任何变化,无论我将其打开是真还是假,重新启动 window 或 vscode 完全,什么都没有)。
I've found a fix with semantic token color customization and now (inspired by Rider) the code looks something like this:我找到了语义标记颜色自定义的修复程序,现在(受 Rider 的启发)代码看起来像这样:
I'm using High Contrast theme (which is built-in I believe) with these rules in settings.json:我在 settings.json 中使用带有这些规则的高对比度主题(我相信这是内置的):
"editor.semanticTokenColorCustomizations": {
"enabled": true,
"rules": {
"parameter": {
"foreground": "#FFFFFF",
"fontStyle": "italic",
},
"class": {
"foreground": "#C191FF",
"fontStyle": "underline",
},
"class.static": {
"fontStyle": "bold underline",
},
"field": "#66C3CC",
"property": "#66C3CC",
"plainKeyword": "#6C95EB",
"number": "#ED94C0",
"method": "#33CC8F",
"local": "#FFFFFF",
"controlKeyword": "#6C95EB"
}
}
The credit goes to Npras from this post . 这篇文章的功劳归于 Npras。 To be honest, it took me a while to even find that post, so I hope some people in the future like me that couldn't even find the name of the feature as well will at least find my post.老实说,我什至花了一段时间才找到那个帖子,所以我希望将来像我这样连功能名称都找不到的人至少能找到我的帖子。
Two things worth mentioning - I don't think my second need can be achieved currently with semantic tokens, and also I've learned that most themes color properties and fields differently, which I personally do not like.有两件事值得一提——我认为我的第二个需求目前无法通过语义标记来实现,而且我了解到大多数主题的颜色属性和字段都不同,我个人不喜欢这些。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.