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

Does not want work until initialize config #1451

Closed
tonn opened this issue Sep 28, 2018 · 6 comments
Closed

Does not want work until initialize config #1451

tonn opened this issue Sep 28, 2018 · 6 comments
Labels

Comments

@tonn
Copy link

tonn commented Sep 28, 2018

There is tsconfig.json in root folder of my project already. But typescript plugin does not want work until I implicitly call "Typescript: Initialize config". There is no changes in tsconfig.json after call that command.

atom 1.31.1
atom-typescript 12.6.3

@tonn tonn changed the title Want work until initialize config Does not want work until initialize config Sep 28, 2018
@lierdakil
Copy link
Collaborator

To save resources, atom-typescript is only really started on a strict on-demand basis. "Demand" is a TypeScript file being opened in this case (or, more precisely, when a TypeScript grammar is used). Or, as you figured out, running initialize config command would do that too since you usually want to initialize config before the project even has any TypeScript files. This is not a bug.

@tonn
Copy link
Author

tonn commented Oct 9, 2018

TypeScript file being opened

Of course I open ts-files. https://i.imgur.com/Y7pGv03.gifv

@lierdakil
Copy link
Collaborator

Hmm. Okay. Do you have any community TypeScript grammars installed? We can't really support those, due to those often creating conflicts with bundled language-typescript.

(to be clear, I'm on Atom 1.31.2 and I can't reproduce, atom-typescript works as expected. So I'm assuming the issue is the result of interaction with your particular environment, not necessarily a problem with the package itself)

@tonn
Copy link
Author

tonn commented Oct 9, 2018

Yes, I use language-typescript-grammars-only instead built-in language-typescript to get inline html-code highlight.
Ok, if it is not a bug, may be it is feature request to get more clear behavior so user can realize why there is no code-suggestions and tooltips for typescript-code?

@lierdakil
Copy link
Collaborator

So, okay, a bit of background.

Atom has two mechanisms for deferred package activation: activation on command and activation on a grammar package being used. Activating atom-typescript unconditionally on Atom start is obviously not so good for performance reasons. Both of those mechanisms are static, meaning those can't be configured after package installation. So we're currently activating on language-typescript being used (since it's the "official" TypeScript language package).

Also, until atom-typescript is activated, we can't really show any notifications or anything else for that matter, due to, well, the package not being active. So we can't really notify the user that he's using an unsupported grammar until they use the supported grammar, at which point it's already late, obviously. So yeah, a bit of a chicken-and-egg problem here.

In theory, we could activate on other grammar packages being used. But deciding which ones is not necessarily straightforward, since supporting a grammar package is essentially endorsing it. And endorsing packages that are unmaintained, potentially broken, etc isn't something I think we should do. And there isn't one "definitive" community TypeScript grammar package that I am aware of.

The "proper" way to get what you want is to pester upstream about adding the features you want. language-typescript is downstream from https://github.com/Microsoft/TypeScript-TmLanguage, so that's the place to start. But this way is long and ardous, so I can understand the desire for a "quick fix".

Anyway, the best I can offer atm is a bit of a hack. You could manually trigger the grammar-used event so that atom-typescript is started when an unsupported grammar is used. Something like this in your init script should do it I believe:

#change package name in the next line if needed
do (grammarPackageImUsing = "language-typescript-grammars-only") ->
  atom.packages.onDidTriggerActivationHook "#{grammarPackageImUsing}:grammar-used", ->
    atom.packages.triggerActivationHook 'language-typescript:grammar-used'

(restart Atom for it to take an effect)

I guess I could add this hack to the FAQ page.

@github-actions
Copy link

This issue has been marked as stale because it did not have any activity for the last 90 days or more. Remove the stale label or comment or this will be closed in 14 days

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

No branches or pull requests

2 participants