如何仅为一种语言启用VS Code的语义高亮?

huangapple go评论64阅读模式
英文:

How to turn on VS Code's semantic highlighing only for one language?

问题

我想仅为Rust启用语义突出显示,而不是其他语言,但实际上似乎不可能。

在定义了“semanticTokenColors”之后,它会为所有语言打开语义突出显示,而不仅仅是Rust。我已经在VS Code的存储库上报告了这个问题,但到目前为止还没有回应。

我尝试将“semanticTokenColors”放在themecolor.json和settings.json中。

以下是我的当前设置:

英文:

I want to have semantic highlighting only for Rust and not other languages, but this seems not to be possible in practice.

After defining the "semanticTokenColors" it turns on semantic highlighting for all languages, not only for Rust. I've made an issue report on VS Code's repo but so far no response.

I've tried putting "semanticTokenColors" on the themecolor.json and in the settings.json.

Here are my current settings:

    "editor.semanticHighlighting.enabled": false,
    "[rust]": {
        "editor.semanticHighlighting.enabled": true
    },
    "editor.semanticTokenColorCustomizations": {
        "[JetBrains Darcula Theme]": {
            "rules": {
                "*.attribute": {
                    "foreground": "#BBB529"
                },
                "lifetime": {
                    "foreground": "#20999D"
                },
                "typeParameter": {
                    "foreground": "#20999D"
                },
                "*.mutable": {
                    "foreground": "#BCA5C4",
                    "underline": true
                },
                "macro": {
                    "foreground": "#4EADE5"
                },
                "macroBang": {
                    "foreground": "#4EADE5"
                },
                "enumMember": {
                    "foreground": "#9876AA"
                },
                "*.constant": {
                    "foreground": "#9876AA"
                },
                "string": {
                    "foreground": "#6A8759"
                },
                "unresolvedReference": {
                    "foreground": "#9876AA"
                },
                "operator": {
                    "foreground": "#abb2bf"
                }
            }
        }
    }

答案1

得分: 1

  • 在用户/全局设置中禁用它
  • settings.json中创建一个rust语言设置并启用它
"editor.semanticHighlighting.enabled": false,
"[rust]": {
  "editor.semanticHighlighting.enabled": true
}
英文:
  • disable it in User/Global setting
  • create a rust language setting in settings.json and enable it
  "editor.semanticHighlighting.enabled": false,
  "[rust]": {
    "editor.semanticHighlighting.enabled": true
  }

答案2

得分: 0

"variable.readonly:java is called a selector and has the form (|tokenType)(.tokenModifier)(:tokenLanguage)?"
根据官方 VS Code 指南 ,我发现了如何在 semanticTokenColors 中指定语言的方法。

英文:

While the original issue still prevails, I found out how to specify the language in semanticTokenColors: "variable.readonly:java is called a selector and has the form (|tokenType)(.tokenModifier)(:tokenLanguage)?.", according to the official vs code guide.

huangapple
  • 本文由 发表于 2023年5月6日 22:58:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76189559.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定