skip to Main Content

I’ve been trying to customize a color theme in VS Code and fiddled around with some properties a little bit. I found out that some properties are theme-dependant.

I’ve been sitting on attempting to customnize function calls as I found a theme that is nearly perfect but I am having trouble distingushing the calls from variables. I’ve tried something like this:

//color customization
"editor.tokenColorCustomizations": {
        "[Night Owl Black (No Italics)]": [
            {
                "textMateRules": {
                    "scope": "meta.function-call.Python",
                    "settings": {
                        "foreground": "#60c0e0",
                        // "fontStyle": ""
                    },
                },
            },
        ],
    },

However, this doesn’t seem to do anything. I also tried a different textmate token meta.function-call.generic.python with no luck

I’ve tried using semantic token highlighting but enabling them just turns syntax highlighting into a rainbow barf.

2

Answers


  1. If you want to modify the color when calling a function, you can use the following settings:

      "editor.tokenColorCustomizations": {
        "textMateRules": [
          {
            "scope": "meta.function-call",
            "settings": {
              "foreground": "#60c0e0"
            }
          }
        ]
      }
    
    Login or Signup to reply.
  2. With semantic highlighting, you can do this:

    "editor.semanticTokenColorCustomizations": {
       "[Monokai]": { // remove this wrapper to apply to all themes
          "rules": {
             "function:python": "#ff0000" // remove ":python" to apply to all languages
          }
       }
    },
    

    See also the editor.semanticHighlighting.enabled setting, the enabled property of editor.semanticTokenColorCustomizations settings, and https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide.


    With token colourization (and semantic highlighting enabled), the following two work pretty well (but not when semantic highlighting is disabled):

    "editor.tokenColorCustomizations": {
       "[Monokai]": { // remove this wrapper to apply to all themes
          "functions": "#FF0000",
       }
    }
    
    "editor.tokenColorCustomizations": {
       "[Monokai]": { // remove this wrapper to apply to all themes
          "textMateRules": [
             {
                "scope": "entity.name.function", // applies to all languages
                "settings": {
                   "foreground": "#FF0000",
                }
             },
          ]
       }
    }
    

    With semantic highlighting disabled, it seems trickier, having to write more scopes. I’m not sure if I’ve covered everything here:

    "editor.tokenColorCustomizations": {
       "[Monokai]": { // remove this wrapper to apply to all themes
          "textMateRules": [
             {
                "scope": "meta.function-call.python, support.function.builtin.python", // remove ".python" to apply to all languages
                "settings": {
                   "foreground": "#FF0000",
                }
             }
          ]
       }
    }
    

    Note that the above will also colour the parentheses and anything in them that don’t have their own token colourization rules.


    If you want to disable semantic highlighting for a particular language mode, you can do this:

    "[python]": {
       "editor.semanticHighlighting.enabled": false
    },
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search