【问题标题】:Function highlighting with monokai in VS Code / Atom and Sublime在 VS Code / Atom 和 Sublime 中使用 monokai 突出显示功能
【发布时间】:2017-09-04 20:20:19
【问题描述】:

在使用 Monokai 颜色主题运行 Sublime Text 3 和 VS Code(或 Atom)时,Sublime Text 语法高亮使用蓝色进行函数调用,如下例所示

但是,当我使用 monokai 主题在 VS Code 中打开相同的代码时,函数不会被涂成蓝色

我真的很想改变这一点,代码看起来更好,突出显示了函数调用。但是,我环顾网络,找不到如何改变这种行为。有人对此有什么建议吗?

谢谢!

【问题讨论】:

  • 您使用的是完全相同的.tmTheme 文件还是不同版本的Monokai 主题?有无数版本的 Monokai,但有些版本可能不如其他版本忠实。但是,语法语法也会影响代码的颜色。
  • 有同样的错误,没有找到解决办法
  • 我想回答你的问题here

标签: sublimetext3 visual-studio-code


【解决方案1】:

请参阅下面的更新!


似乎我找到了一个临时解决方案。转到此文件夹(如果您使用的是 Mac)/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/theme-monokai/themes 并将此代码放入 monokai-color-theme .json 文件:

{
    "name": "Function call",
    "scope": "meta.function-call.generic",
    "settings": {
        "foreground": "#66d9efff"
    }
},

这是一个示例: screenshot

但请记住,主题更新后这些更改可能会消失!

更新: 在突出显示遇到了一些麻烦之后,我决定将带有主题的文件上传到 GitHub 并保持最新状态。因此,如果您不想深入研究代码,只需查看我的存储库:https://github.com/spyker77/monokai-theme-extended


更新(2021 年 4 月)

事实证明,以前的解决方案是不可持续的。因此,目前更好的可能是:

  1. 在 Visual Studio Code 中,转到“代码”=>“首选项”=>“颜色主题”并选择 Monokai
  2. 打开settings.json文件(how-to);
  3. 其中可能已经有很多设置,所以您只需在末尾和右大括号之前添加以下自定义项(不要忘记在您继续最后一个设置之后的尾随逗号) :
"editor.tokenColorCustomizations": {
        "[Monokai]": {
            "textMateRules": [
                {
                    "name": "Decorator definition decorator",
                    "scope": "punctuation.definition.decorator.python",
                    "settings": {
                        "foreground": "#F92672"
                    }
                },
                {
                    "name": "Meta function-call",
                    "scope": "meta.function-call.generic.python",
                    "settings": {
                        "foreground": "#66D9EF"
                    }
                },
                {
                    "name": "Storage type function async",
                    "scope": "storage.type.function.async.python",
                    "settings": {
                        "foreground": "#F92672",
                    }
                },
                {
                    "name": "Punctuation separator period",
                    "scope": "punctuation.separator.period.python",
                    "settings": {
                        "foreground": "#F8F8F2",
                    }
                },
                {
                    "name": "Entity name function decorator",
                    "scope": "entity.name.function.decorator.python",
                    "settings": {
                        "foreground": "#66D9EF",
                    }
                },
                {
                    "name": "Entity name type class",
                    "scope": "entity.name.type.class.python",
                    "settings": {
                        "fontStyle": ""
                    }
                },
                {
                    "name": "Entity other inherited-class",
                    "scope": "entity.other.inherited-class.python",
                    "settings": {
                        "fontStyle": "italic"
                    }
                },
                {
                    "name": "Support type python",
                    "scope": "support.type.python",
                    "settings": {
                        "fontStyle": ""
                    }
                },
                {
                    "name": "String quoted docstring multi python",
                    "scope": "string.quoted.docstring.multi.python",
                    "settings": {
                        "foreground": "#88846F",
                    }
                }
            ]
        }
    }

【讨论】:

    【解决方案2】:

    在尝试了服务器数小时后终于找到了解决方案,我回来与您分享解决方案,因为我尝试了上面的答案但无法使其工作。 原来是我用VScode扩展(python for Vscode)的问题,所以先禁用它,extension

    然后转到您的setting.json 文件how to open setting

    将此添加到文件顶部

    "editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope": "meta.function-call.generic",
                "settings": {
                    "foreground":"#19D1E5"
                }
            }
        ]
    },
    

    并重新启动 VScode,这应该可以工作,顺便说一句,我正在使用 monokai vibrent,我相信它可以在你喜欢的任何主题中工作。 setting.json

    喜欢这个here

    【讨论】:

      【解决方案3】:

      在 settings.json 中:

      "editor.tokenColorCustomizations": {
        "[Monokai]": {
          {
            "scope": "entity.name.function",
            "settings": {
            "foreground": "#fdc306d0",  // use your desired color
            "fontStyle": "underline"    // I like this, foreground color has some reduced opacity
           }
         }
       }
      }
      

      可能会成功。

      【讨论】:

        猜你喜欢
        • 2012-05-10
        • 2020-03-16
        • 1970-01-01
        • 2018-02-14
        • 2023-02-08
        • 1970-01-01
        • 2018-09-25
        • 1970-01-01
        • 2021-11-07
        相关资源
        最近更新 更多