问题
I have custom output from API and I want to format it to string with some colored values.
回答1:
The output channel can be colorized with a TmLanguage grammar. The Output Colorizer extension extension does exactly that:
You can do this by targeting the text/x-code-output
mimetype:
"contributes": {
"languages": [{
"id": "code-output",
"mimetypes": [
"text/x-code-output"
]
}],
"grammars": [{
"language": "code-output",
"scopeName": "code.output",
"path": "./syntaxes/code-output.tmLanguage"
}]
}
However, since this colorization is mimetype-based, you can't apply the highlighting to a specific output channel only. This means that two extensions providing output channel colorization will conflict.
来源:https://stackoverflow.com/questions/55524643/vscode-extension-how-to-render-colored-output-in-output-channel