microsoft / microsoft/TypeScript-TmLanguage

Theming: Distinguish between `import` types

Open
#939 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
471
Forks
149
PR merge metrics
No merged PRs in 30d

Description

In Atom, we can theme imports based on the type of thing being imported. As you can see below, import aliases/names are styled differently than the class Knex being imported. This has always been immensely handy for at a glance differentiation and validation of imports as well as for organizing imports.

Screen Shot 2022-11-16 at 11 27 36 PM

Below is the same theme applied to VS Code, but without the ability to differentiate.

Screen Shot 2022-11-16 at 11 27 49 PM

I believe this comes down to a lack of TextMate scope. Here are the available scopes for makeContext:

variable.other.readwrite.alias.ts
meta.import.ts
source.ts

And the available scopes for Knex:

variable.other.readwrite.alias.ts
meta.block.ts
meta.import.ts
source.ts

My ignorant suggestion: it would probably be enough to catch capital-cased aliases for adding an additional scope.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TypeScript grammar rules involved in makeContext and compare the scopes shown for the import alias and Knex. Determine how imported names are currently classified and define the distinct scope needed for theming. Done means import aliases and imported classes can be styled differently, with the resulting scopes verified against the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.