microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.71k stars 767 forks source link

Improve semantic highlighting of `TypeAlias` #3100

Open xiaoxi-david opened 2 years ago

xiaoxi-david commented 2 years ago

I wonder if:

Example: alias_test

I am using:

debonte commented 7 months ago

Similarly, consider behavior of NewType -- https://github.com/microsoft/pylance-release/issues/3754

jnooree commented 4 months ago

Any updates on this?

rchiodo commented 4 months ago

Sorry but this is not currently planned. However you can get this somewhat by yourself.

The TypeAlias is flagged with a typehint modifier in the semantic token. This allows you to override the color:

image

    "editor.semanticTokenColorCustomizations": {
        "[Default Dark Modern]": {
            "rules": {
                "*.typeHint": "#4EC9B0"
            }
        }
    }

Which for me, gives the same color for the typehint as the original type.

image

jnooree commented 4 months ago

Great, I'll try for it. Thanks!

jnooree commented 4 months ago

It works for type hints only, so I think pylance should still provide separate semantic tokes for type aliases (or mark them as types or classes at least).

Anyway, the type hint trick is better than nothing, thanks for the suggestion.

Isuxiz commented 3 weeks ago

Really need this feature!