Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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:

enter image description here

like image 459
Yohan.sb Avatar asked Jul 13 '26 08:07

Yohan.sb


1 Answers

See the theming docs and 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": {
    "[Theme Name Goes Here]": { // remove this wrapper to apply to all themes
        "rules": {
            "function:python": { // remove ":python" to apply to all languages
                "foreground": "#FF0000", // TODO
                // "fontStyle": "" // optional
            }
        }   
    }
}

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

If you want the call for function declarations to be different, then write another similar rule, but use the declaration modifier. Ex. function.declaration:python.


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": {
    "[Theme Name Goes Here]": { // remove this wrapper to apply to all themes
        "textMateRules": [
            {
                "scope": "meta.function-call.python",
                "settings": {
                    "foreground": "#FF0000", // TODO
                    // "fontStyle": "" // optional
                }
            }
        ]
    }
},

See also the scopes support.function.builtin.python, meta.function-call.generic.python, and meta.member.access.python, meta.function-call.python.

like image 60
starball Avatar answered Jul 17 '26 23:07

starball