MagicPython icon indicating copy to clipboard operation
MagicPython copied to clipboard

Ability to colorize imports?

Open Syntaf opened this issue 3 years ago • 4 comments

  • 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!

Syntaf avatar Sep 14 '20 16:09 Syntaf

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?

1st1 avatar Sep 14 '20 23:09 1st1

Maybe they no longer use MP?

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

elprans avatar Sep 15 '20 00:09 elprans

That explains the bugs, sigh.

1st1 avatar Sep 15 '20 00:09 1st1

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!

Syntaf avatar Sep 15 '20 21:09 Syntaf