akamud / vscode-theme-onelight

VSCode Theme based on Atom's One Light theme
MIT License
79 stars 54 forks source link

Discrepancies Python built-ins #8

Closed TiemenSch closed 7 years ago

TiemenSch commented 7 years ago

Thanks for porting this awesome theme to VS Code!

I am currently using: Atom One Light Theme 2.0.3 VS Code 1.14.2

And saw some discrepancies.

None the styling of the Python keywords like None is off as in it looks like plain text. I cannot confirm how this would extrapolate to other languages, but I fixed it by adding

        {
            "scope": "constant.language.python",
            "settings": {
                "foreground": "#986801"
            }
        }

To the tokencolors. That may be too broad, but works for now.

__name__ However, I can't seem to find how to correctly highlight built-ins like __name__.

In Atom, they also get the brighter-orange color, but in your theme they are highlighted as plain text.

I could not find which tokens these are.

Any ideas?

akamud commented 7 years ago

Thanks for taking the time reporting this. I'll have to investigate this issue. The problem usually is that the tokenization process is different from Atom and VSCode and sometimes we don't have a narrow enough scope to apply coloring.

I'll have to take a look at this later.

I'm not a Python developer, can you please provide me a Python sample with the cases you mentioned, please?

TiemenSch commented 7 years ago

Sure! In the meantime I found another one (hope you don't mind). It happens on function arguments and their classes. Code example:

from numpy import ndarray

def myfun(myvar: ndarray=2):
    return 0

if __name__ is '__main__' and not None:
    pass

Image sample

TiemenSch commented 7 years ago

For me, the None case was most essential. It's used a lot in Python code and not seeing it getting highlighted makes me wonder twice if I've typed it correctly all the time. __name__ and other built-ins are very often used as well.

The function argument highlighting is actually off in Atom itself.

akamud commented 7 years ago

Thank you so much for providing so much detail. When I investigate everything I'll let you know if this is something that can be done.

akamud commented 7 years ago

Python is a tough one to get right. The tokens are reused a lot in VSCode.

I released a new version with a bunch of improvements, including the __name__ and None cases. These fixes are in version 2.0.4.

Some things I could not fix:

The built-in function are commonly raised as an issue to me, but VSCode does not provide a way to customize it with no side-effects. For example: print and list() are classified with the same tokens. Atom shows them in different colors.

The parameters and arguments are also very difficult, I can't differentiate them as you suggested. So while I could fix ndarray coloring, I can't fix myvar coloring without generating a bunch of side-effects.

For example, this code shows the parameters as orange now, but if I changed myvar to be gray, they all would look gray too.

def split_on_nth(string, split_character, span=1):
    """Split string on Nth split_character"""
    items = string.split(split_character)
    return [split_character.join(items[i:i + span]) for i in range(0, len(items), span)]

I decided to keep them as orange because this is the closest to Atom at the moment.

If you think Atom's colors are of themselves, you can customize it for your VSCode using the token variable.parameter.function.language.python

This is how it looks now:

screen shot 2017-09-23 at 14 04 09