How to change the color of python function calls?


#1

Hi everyone,

I’m trying to change the color of function calls in python code (or in any language, for that matter). In the Developer console, the function call appears as “meta function-call python”. But how exactly should I add the color change and where?

Thanks


#2

You should write a custom syntax theme


#3

@popas90 you can add that in your user stylesheet:

atom-text-editor, atom-text-editor::shadow {
  .meta.function-call.python {
    color: '#abcde';
  }
}

#4

Great, that worked! Thanks :slight_smile:


#6

For future viewers:
.meta.function-call.python also colors the function’s parameters. If you want only the function name colored, use .meta.function-call.generic.python.


#8

It doesn’t work for me, Atom 1.18. It says:

Starting from Atom v1.13.0, the contents of atom-text-editor elements are no longer encapsulated within a shadow DOM boundary. This means you should stop using :host and ::shadow pseudo-selectors, and prepend all your syntax selectors with syntax–. To prevent breakage with existing style sheets, Atom will automatically upgrade the following selectors:

atom-text-editor .meta.function-call.python, atom-text-editor::shadow .meta.function-call.python => atom-text-editor .meta.function-call.python, atom-text-editor.editor .syntax–meta.syntax–function-call.syntax–python

Automatic translation of selectors will be removed in a few release cycles to minimize startup time. Please, make sure to upgrade the above selectors as soon as possible.

I’m beginner. Can you help me to make highlighting function call and methods work in Atom 1.18? Should it be like this:

atom-text-editor {
  .meta.function-call.python {
    color: '#66D9EF';
  }
}

atom-text-editor.editor {
  .syntax--meta.syntax--function-call.syntax--python
  }
}

How to setup Atom's 'styles.less' file to highlight function and method call in Python?
#9

This works, yes, but you need another { at the end of the second line.


#10

I installed magicpython instead of python-language package. Highlighting works now in Material theme without this hack. But when I change a theme in Monokai, it doesn’t work, with or without this edit.