Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Syntax highlighting/colors are still broken? #65713

Closed
rebelC0der opened this issue Dec 27, 2018 · 18 comments
Closed

Python Syntax highlighting/colors are still broken? #65713

rebelC0der opened this issue Dec 27, 2018 · 18 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug *duplicate Issue identified as a duplicate of another issue(s) languages-basic Basic language support issues
Milestone

Comments

@rebelC0der
Copy link

rebelC0der commented Dec 27, 2018

Hi!

There was a bug/discussion about this before here: #1467
But reading it, I see no resolution.

VSCode's Python syntax highlighting still broken after all plugins are installed. Here is an example of Monokai themes on VSCode and Sublime:

Is/Can this be fixed at all ? I see no way to modify JUST the syntax color scheme in VSCode. Sublime and Atom do not have that problem.

No matter what theme is selected, none of the methods are highlighted.

image

Regards.

@rebelC0der
Copy link
Author

@nchammas @aeschli @bpasero @joaomoreno Any news on this ? C++ code highlighting seems to be fine, but not Python.

@octref octref added the *caused-by-extension Issue identified to be caused by an extension label Dec 28, 2018
@vscodebot
Copy link

vscodebot bot commented Dec 28, 2018

This issue is caused by an extension, please file it with the repository (or contact) the extension has linked in its overview in VS Code or the marketplace for VS Code. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Dec 28, 2018
@octref
Copy link
Contributor

octref commented Dec 28, 2018

Please report to https://github.com/Microsoft/vscode-python, with your Python extension version.

@rebelC0der
Copy link
Author

rebelC0der commented Dec 28, 2018

@octref
Can you please take a look at this post here: microsoft/vscode-python#2768

"We actually don't handle the syntax highlighting; it comes from VS Code who gets it from MagicPython."

Also, in MagicPython extension it says this: "Attention VSCode users: MagicPython is used as the default Python highlighter in Visual Studio Code. Don't install it unless you want or need the cutting edge version of it. You will likely see no difference because you're already using MagicPython."

Disabling all Python extensions, enabling just MagicPython, or just Python extension does not change a thing. Python syntax highlighting is still broken.

screenshot_20181228_143009

Please, don't just close this, as this has been an issue for some time now and has not been resolved.

@octref
Copy link
Contributor

octref commented Dec 28, 2018

Ok, sorry. Does this start to happen with 1.30, or sometime earlier?

Can you also paste the py-imports code so I can try it?

@octref octref reopened this Dec 28, 2018
@octref octref added bug Issue identified by VS Code Team member as probable bug languages-basic Basic language support issues and removed *caused-by-extension Issue identified to be caused by an extension labels Dec 28, 2018
@octref octref self-assigned this Dec 28, 2018
@rebelC0der
Copy link
Author

Thanks!

I am running this:

Version: 1.30.1
Commit: dea8705087adb1b5e5ae1d9123278e178656186a
Date: 2018-12-18T18:07:32.870Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
OS: Linux x64 4.18.0-3-amd64

I only started using from 1.30.1, but from previous comments/bugs, it seems this problem was there since few version back.

If by py-imports code you mean some code you can copy-past into your editor, then jus tyryu what I have in the image above:

import random
import datetime
import math

class Mapping:
    def init(self, iterable):
        self.items_list = []
        self.__update(iterable)

    def update(self, iterable):
        for item in iterable:
            self.items_list.append(item)

    __update = update

class MappingSubclass(Mapping):
    def update(self, keys, values):
        for item in zip(keys, values):
            self.items_list.append(item)


print(random.randint(1, 10))
print(math.radians(90))
print(math.sin(90))
print(math.degrees(3.5))
today = datetime.date.today()
print(today)

This is a basic example. It should at least highlight methods like
os.version
math.sin(20)

image

Also this is still true:
microsoft/vscode-python#2768

@octref
Copy link
Contributor

octref commented Dec 28, 2018

Try this setting:

  "editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "scope": "meta.function-call.generic.python",
        "settings": {
          "foreground": "#FF0000"
        }
      }
    ]
  },

You can change the foreground to any color you want.
The problem is our bundled themes do not color that scope, so this syntax highlight is lost.

@octref octref added this to the Backlog milestone Dec 28, 2018
@rebelC0der
Copy link
Author

@octref
That actually works. Thank a lot. Do you know if this is something to be fixed/added to next releases so we don't have to do it by hand? And there is no way to just choose syntax coloring scheme for now. this would be a big plus to have like in other editors.

@octref
Copy link
Contributor

octref commented Dec 28, 2018

@RebelCoderRU Well, that means adding that scope to the theme-extensions https://github.com/Microsoft/vscode/tree/master/extensions. I don't know if we usually do that (the guy maintaining themes is out of office).

@rebelC0der
Copy link
Author

But syntax color scheme selection is absolutely needed. + syntax highlighting is actually broken (if you compare to any other editor) and this has been reported countless times and always has been closed.

What is the best way to go about requesting fix/addition of this?

@Astrantia
Copy link

@RebelCoderRU Use a different theme or create your own theme

@octref
Copy link
Contributor

octref commented Dec 28, 2018

Syntax color selection won't help much, and it's usually not a good idea because the syntax color depends largely on background, so it needs a matching theme.

@rebelC0der
Copy link
Author

rebelC0der commented Dec 28, 2018

@Astrantia as it was mentioned in other closed threads on this matter, changing to any theme does not effect syntax highlighting in any way. It is always broken. I have also tried 30+ themes. No changes.

@octref but changing themes still does not fix syntax highlighting issue. Try it, switch between themes and see how functions and methods are never highlighted at all. Now with your little hack it is better but still not good.

So there is obviously a problem with correct syntax highlighting as there were more then 1 bug opened/closed on that matter.

In Sublime Text: you can choose tons of different Syntax color themes completely separately from any other colors.
In Atom - same, there are two options to change - Color Scheme (UI) and Syntax Color Scheme.
But in both editors, syntax highlighting works correctly, highlighting things like in images above.

In VSCode, changing theme does not change or fix syntax highlighting. I definitely think it is a bug.

@rebelC0der
Copy link
Author

@octref I can see you have "added this to the Backlog milestone an hour ago"
Hope this will get looked at. Thanks.

@Astrantia
Copy link

@RebelCoderRU That's because the themes you are using do not color that scope. As I said either create your own theme or edit the themes you are using. Separate ui color scheme and syntax color scheme is a completely different issue.

@octref
Copy link
Contributor

octref commented Dec 28, 2018

Meanwhile you can take a look at https://code.visualstudio.com/api/extension-capabilities/theming for some info on theme colors vs syntax colors.

@aeschli
Copy link
Contributor

aeschli commented Jan 3, 2019

The problem is with the scope that MagicPython uses for function references.

The issue is already filed: MagicStack/MagicPython#127

@aeschli aeschli closed this as completed Jan 3, 2019
@aeschli aeschli added the *duplicate Issue identified as a duplicate of another issue(s) label Jan 3, 2019
@1st1
Copy link

1st1 commented Jan 16, 2019

@RebelCoderRU MagicPython does parse function calls and assigns them a separate distinct scope "meta.function-call.generic.python". It's now up to VSCode's syntax color themes to assign a color to that scope.

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug *duplicate Issue identified as a duplicate of another issue(s) languages-basic Basic language support issues
Projects
None yet
Development

No branches or pull requests

5 participants