首页 > 解决方案 > 无法在 VSCode for PHP 中更改 DocBlock 注释颜色

问题描述

我到处看了看,但没有运气。我的 VS Code 主题中的 DocBlock 注释有 3 种不同的颜色(见截图)。我希望这一切都是灰色的(只有一种颜色)。我意识到这取决于主题本身(我正在使用Atom One Dark)。我该如何更改它以使评论文本为一种颜色(灰色)?

我可以使用此设置更改 javascript 的 DockBlock 注释,但它仅适用javascriptPHP.

    "editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "name": "storage.type.class.jsdoc",
                "scope":
                "storage.type.class.jsdoc,entity.name.type.instance.jsdoc,variable.other.jsdoc",
                "settings": {
                    "foreground": "#5c6370"
                }
            }
        ],
    },

这也不起作用

    "editor.tokenColorCustomizations": {
        "comments": "#5c6370",
    },

屏幕截图(如您所见,我的评论有 3 种颜色 - 灰色、紫色和黄色)

Yaktocat 的图像

标签: phpvisual-studio-codeeditorvscode-settings

解决方案


感谢@rioV8,我能够完全实现我想要的。settings.json因此,如果其他人正在寻找解决方案,我将分享我的。

我还了解到,您可以通过用空格分隔多个范围来选择它们。但是顺序很重要,看起来需要与检查编辑器显示的顺序相反。去搞清楚..

这是我的settings.json (用于 javascript 和 PHP 评论)

"editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope": "storage.type.class.jsdoc,entity.name.type.instance.jsdoc,variable.other.jsdoc",
                "settings": {
                    "foreground": "#485c6c"
                }
            },

            {
                "scope": "storage.type.class.jsdoc punctuation.definition.block.tag.jsdoc",
                "settings": {
                    "foreground": "#485c6c"
                }
            },

            {
                "scope": "comment.block.documentation.phpdoc.php",
                "settings": {
                    "foreground": "#5c6370"
                }
            },

            {
                "scope": "keyword.other.phpdoc.php,comment.block.documentation.phpdoc.php",
                "settings": {
                    "foreground": "#76687d"
                }
            },

            {
                "scope": "keyword.other.type.php,meta.other.type.phpdoc.php,comment.block.documentation.phpdoc.php",
                "settings": {
                    "foreground": "#76687d"
                }
            },

            {
                "scope": "support.class.php",
                "settings": {
                    "foreground": "#E5C07B"
                }
            },

            {
                "scope": "meta.other.type.phpdoc.php,comment.block.documentation.phpdoc.php",
                "settings": {
                    "foreground": "#5c6370"
                }
            },

            {
                "scope": "meta.other.type.phpdoc.php support.class.php",
                "settings": {
                    "foreground": "#5c6370"
                }
            },
            
            {
                "scope": "meta.other.type.phpdoc.php support.class.builtin.php",
                "settings": {
                    "foreground": "#5c6370"
                }
            },
        ],
    }

推荐阅读