microsoft / TypeScript-TmLanguage

TextMate grammar files for TypeScript for VS Code, Sublime Text, and Atom.
MIT License
415 stars 130 forks source link

Theming: Distinguish between `import` types #939

Open shellscape opened 2 years ago

shellscape commented 2 years ago

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.

aeschli commented 2 years ago

This is a TypeScript grammar / semantic highlighing issue Note: we decided against semantic highlighting on imports. https://github.com/microsoft/vscode/issues/93017 is the request to add this back again.

shellscape commented 2 years ago

@aeschli it looks like your last reply https://github.com/microsoft/vscode/issues/93017#issuecomment-949913282 was a direction to open an issue with the TS project - I'm not sure that anyone without intimate knowledge of the interaction between the TS language server and vscode is going to know what to put in an issue. I certainly wouldn't.

shellscape commented 2 years ago

In giving this some more thought - wouldn't this also apply to ESM imports? When looking at a .mjs file for example, the scopes become:

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

and

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