45

https://code.visualstudio.com/docs/languages/css

当前的插件都不能这样做。我真的很惊讶。即使是intellij也有这种支持!

同样来自 vscode 本身的回复也有点没有帮助。 https://github.com/Microsoft/vscode/issues/36485

关于如何构建这样的插件的任何提示,似乎不应该真的很难,因为它实际上只是将功能从一个文件扩展名移植到另一个文件扩展名?

任何人都能够解决这个问题?

4

7 回答 7

56

我发现colorize可以突出显示JavaScriptTypeScript(以及其他)GitHub

在您settings.jsonVSCode中,只需添加您想要定位的语言:

"colorize.languages": ["typescript", "javascript", "css", "scss"]

enter image description here

于 2019-07-28T15:38:11.507 回答
18

对于任何使用Colorize并希望它在他们的 React 项目(js 中的 css 等)上工作的人:

采用

"colorize.languages": ["javascriptreact", "javascript", "css", "scss"]

因为显然需要“javascriptreact”而不是“javascript”

对于反应中的打字稿,请使用“javascriptreact”。

于 2020-02-22T02:35:38.707 回答
4

Updating for this question. Seems like:

https://marketplace.visualstudio.com/items?itemName=AntiAntiSepticeye.vscode-color-picker

adds color picker brings functionality into other languages.

Personally tested and works in typescript. It's relatively new so it doesn't have a lot of downloads or installs but it works as advertised.

于 2021-12-03T03:01:54.190 回答
2

VS extension JSON color token is capable of bringing up the native color picker in any language.

To make this work with JS and React, add this in VS Code's settings.json:

"jsonColorToken.languages": [
    "json",
    "jsonc",
    "javascript",
    "javascriptreact"
  ]

Source: https://github.com/YECHUNAN/json-color-token/issues/2#issuecomment-977261832

于 2021-11-27T13:35:54.510 回答
1

vscode-color-info来自wayncheng的一种可能实现方式

将以下代码添加到 settings.json 中的 colorInfo.languages 应该可以解决问题。确保同时包含所有默认语言,以免它们被禁用。

{
    "selector": "javascript",
    "colors": "css"
}

所以你的 settings.json 应该是这样的:

"colorInfo.languages": [
    {
        "selector": "css",
        "colors": "css"
    },
    {
        "selector": "sass",
        "colors": "css"
    },
    {
        "selector": "scss",
        "colors": "css"
    },
    {
        "selector": "less",
        "colors": "css"
    },
    {
        "selector": "html",
        "colors": "css"
    },
    {
        "selector": "javascript",
        "colors": "css"
    }
]
于 2018-10-19T19:01:03.310 回答
1

它可以"colorize.include": ["**/*.js"]在我的 create-react-app 项目中使用

于 2020-02-02T10:54:50.653 回答
0

I had the problem that TSX (TypeScript files with XML) wouldn't properly highlight the color. The solution was to add "typescriptreact" to the array as described in the post by @rouan.

PS @Ali Mert Cakar it adds no color picker and only highlights the color in the respective color.

于 2021-05-04T07:54:08.840 回答