我创建了一个简单的VS Code扩展,它提供了一组配置设置。这是package.json
中的代码块的简化示例:
"configuration": {
"type": "object",
"title": "abc",
"properties": {
"xyz": {
"type": [
"array"
],
"items": {
"title": "Custom patterns to highlight.",
"type": "object",
"properties": {
"foreground": {
"pattern": "^[^$|^\\s]",
"type": "string",
"title": "The color.",
"description": "The foreground color that will be used for highlighting."
}
}
}
}
}
}
是否有一种方法可以将foreground
设置的类型设置为彩色而不是任何字符串?似乎没有颜色或类似颜色。
如果设置编辑器可以理解它是一种颜色并像本节中那样显示颜色选择器,那就太好了
答案 0 :(得分:2)
您需要添加格式属性:
"myconfig.someColor": {
"type": "string",
"format": "color-hex",
"scope": "resource",
"description": "Some Color"
}
我已经找到了一些文档:
https://github.com/microsoft/vscode/tree/master/extensions/json-language-features/server