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

Ability to colorize imports? #223

Open
Syntaf opened this issue Sep 14, 2020 · 4 comments
Open

Ability to colorize imports? #223

Syntaf opened this issue Sep 14, 2020 · 4 comments

Comments

@Syntaf
Copy link

@Syntaf Syntaf commented Sep 14, 2020

  • Editor name and version: VSCode 1.49.0

  • Platform: Windows 10

  • Color scheme: Dark+

  • MagicPython version: Installed via Python extension v2020.8.108011

  • A sreenshot:
    image

  • 5-10 lines of surrounding code:

from django.utils import timezone
from django.views import generic

from .models import Question, Choice

class IndexView(generic.ListView):
    template_name = 'polls/index.html'
    context_object_name = 'latest_questions'

    def get_queryset(self):
        return Question.active_objects.all().order_by('-pub_date')[:5]

class DetailView(generic.DetailView):
    model = Question
    template_name = 'polls/detail.html'

class ResultsView(generic.DetailView):
    model = Question
    template_name = 'polls/results.html

Just as the above code snippet does, is it possible to colorize class imports in VSCode?

I've tried searching the web for an answer on this topic but couldn't find one; I'm submitting an issue here in hopes of someone either telling me that this is intended but not working, or that this is not supported.

Thanks for any info!

@1st1
Copy link
Member

@1st1 1st1 commented Sep 14, 2020

Just as the above code snippet does, is it possible to colorize class imports in VSCode?

No, not really, because syntax highlighter doesn't know if it's a class or just a weirdly named module.

@vpetrovykh Victor, it's weird that GH highlights that though. Maybe they no longer use MP?

@elprans
Copy link
Member

@elprans elprans commented Sep 15, 2020

Maybe they no longer use MP?

Yeah, it appears they no longer use https://github.com/github/linguist to highlight the source.

@1st1
Copy link
Member

@1st1 1st1 commented Sep 15, 2020

That explains the bugs, sigh.

@Syntaf
Copy link
Author

@Syntaf Syntaf commented Sep 15, 2020

Just as the above code snippet does, is it possible to colorize class imports in VSCode?

No, not really, because syntax highlighter doesn't know if it's a class or just a weirdly named module.

@vpetrovykh Victor, it's weird that GH highlights that though. Maybe they no longer use MP?

Gotcha, thanks for the explanation.

In my project the module naming is fairly consistent where I can guarantee that:

  • A lower case import is a function from x import foo
  • A camel case import is a class from x import FooBar

Is it possible for me to manually colorize these within my theme using the VSCode editor.tokenColorCustomizations setting?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.