如何在VS Code中突出显示Python函数调用?

huangapple go评论67阅读模式
英文:

How can I highlight Python function calls with in VS Code?

问题

我想知道如何在VS Code中使用python启用函数调用的高亮显示。请参见以下示例,其中函数调用为空白,如代码的其他部分所示:

英文:

I would like to know how to enable the highlighting of function call in VS Code with python. See the following example where function call is blank, as other part of the code:

如何在VS Code中突出显示Python函数调用?

答案1

得分: 2

看起来你正在使用的颜色主题并不能以你想要的方式突出显示事物。你可以更改它(请查看命令面板中的“Developer: Inspect Editor Tokens and Scopes”命令)。例如:

语义突出显示自定义路线(需要提供Python语义突出显示支持的语言扩展)(突出显示函数定义和调用):

"editor.semanticTokenColorCustomizations": {
    "[Atom One Dark]": {
        "rules": {
            "function:python": {
                "foreground": "#FF0000", // TODO
                // "fontStyle": ""
            }
        }   
    }
}

^“:python”部分将使颜色自定义仅适用于Python语言的函数。

标记颜色自定义路线(无需任何扩展,因为VS Code捆绑了Python的TextMate语法支持)(可能需要“禁用”为Python提供语义突出显示支持的扩展):

"editor.tokenColorCustomizations": {
    "[Atom One Dark]": {
        "textMateRules": [
            {
                "scope": "meta.function-call.python",
                "settings": {
                    "foreground": "#FF0000", // TODO
                    // "fontStyle": ""
                }
            }
        ]
    }
}
英文:

It seems that the colour theme you are using isn't highlighting things in the way you want. You can change that. (see the Developer: Inspect Editor Tokens and Scopes command in the command palette) Ex.

Semantic highlighting customization route (requires a language extension that provides semantic highlighting support for Python) (highlights both function definitions and calls):

"editor.semanticTokenColorCustomizations": {
    "[Atom One Dark]": {
        "rules": {
            "function:python": {
                "foreground": "#FF0000", // TODO
                // "fontStyle": ""
            }
        }   
    }
}

^the :python part will make the colour customization only apply to functions for the Python language.

Token colour customization route (works without any extensions, since VS Code bundles TextMate grammar support for Python) (may require disabling extensions that provide semantic highlighting support for Python):

"editor.tokenColorCustomizations": {
    "[Atom One Dark]": {
        "textMateRules": [
            {
                "scope": "meta.function-call.python",
                "settings": {
                    "foreground": "#FF0000", // TODO
                    // "fontStyle": ""
                }
            }
        ]
    }
},

答案2

得分: 0

只是关于我使用的主题(Atom One Dark主题),它没有突出显示函数调用。我切换到另一个主题,现在可以了。

英文:

Okay it was just about the theme that I was using ( Atom one dark theme ) that was not highlightning the function call. I switched to another one and it's now working.

huangapple
  • 本文由 发表于 2023年5月17日 22:21:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76273150.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定