Can not highlight keyword.operator.logical for Python language



I try to override some settings of the one dark syntax theme with a ./atom/styles.less file.

Everything works as expected except for the operators belonging to the “keyword.operator.logical.python” scope, which doesn’t seem to take my directives into account.

For instance, I put this in my styles.less:

@pink: hsl(336, 100%, 68%);

atom-text-editor::shadow .keyword.operator.logical {
  color: @pink;

But the keywords associated with the scope keep their original color (which is purple in the one dark syntax theme).

According to the python.cson file of the language-python for atom, the relevant keywords are actually associated with this scope:

'match': '\\b(and|in|is|not|or)\\b'
'name': 'keyword.operator.logical.python' 

Any hints on how to solve this issue?


  1. Put your cursor inside the token you want to know the scope for
  2. Execute the Log Cursor Scopes command using Cmd+Alt+P on OS X or Ctrl+Alt+Shift+P on other platforms

This will display the scopes for the token at the cursor. I would use this to ensure that the token you’re trying to color actually have the scopes you’re expecting.


I’m sorry I wasn’t clear enough but this is how I got the scope in the first place :smile:


Do you have some sample Python code that reproduces the issue?


You can use this snippet that include a lot of keywords:

import time

data = {'a': 1, 'b': 2, 'c': 3}

print('d' not in data)

except KeyError:

print(True and False)

In styles.less:

@import "syntax-variables";

@pink:   hsl(336, 100%, 68%);

atom-text-editor::shadow .keyword.operator.logical {
  color: @pink;

atom-text-editor::shadow .keyword {
  &.other, {
    color: @pink;

You can see that the following keywords are pink:

import, print, try, except, pass. But not, in and ‘and’ stay purple.

I’ve tried different syntaxes in the styles.less but nothing seems to work.


Here’s why:

Notice that:

  1. The style specifies the full .keyword.operator.logical.python, making it more specific than your rule
  2. The style also specifies .source.python, which makes it more specific than your rule even if you specify the full .keyword.operator.logical.python by itself

When I changed your rule to:

atom-text-editor::shadow .source.python {
  .keyword.operator.logical.python {
    color: @pink;

It worked as desired.


This is great, many thanks for your help!