首页 > 解决方案 > 有没有办法在语言扩展中为 `tokenColors` 贡献默认值

问题描述

我研究一种语言的新语法,并引入新的作用域。

我想为这些新范围定义合理的默认颜色,就像可以通过颜色贡献来完成一样

以下示例显示了它是如何完成的colors

{
  "contributes": {
    "colors": [
      {
        "id": "superstatus.error",
        "description": "Color for error message in the status bar.",
        "defaults": {
          "dark": "errorForeground",
          "light": "errorForeground",
          "highContrast": "#010203"
        }
      }
    ]
  }
}

我想tokenColors在我的扩展中设置默认值,例如:

{
  "contributes": {
    "tokenColors": [
      {
        "scopes": ["my.warning.new.scope.waring", "my.warining.other.new.scope"],
        "description": "Color for warning message in unknown .",
        "defaults": {
          "dark": "wariningForeground",
          "light": "wariningForeground",
          "highContrast": "#010203"
        }
      }
    ]
  }
}

我不想创建一个继承自另一个主题的新主题,因为用户必须明确选择它。

我想为范围定义合理的默认值,因为大多数主题不会为我的新范围定义颜色。

有没有办法在不创建新主题的情况下为令牌范围定义默认令牌颜色?

标签: visual-studio-codevscode-extensions

解决方案


推荐阅读