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

feat: add option to force-start svelte plugin #2185

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Conversation

dummdidumm
Copy link
Member

This adds the assumeIsSvelteProject project for the typescript plugin. Some editors like Intellij may use their own detection mechanisms for whether or not a plugin should run, and this allows them to do that and skip our detection mechanism.

@tomblachut does this solve your use case?

This adds the assumeIsSvelteProject project for the typescript plugin. Some editors like Intellij may use their own detection mechanisms for whether or not a plugin should run, and this allows them to do that and skip our detection mechanism.
}

export class ConfigManager {
private emitter = new EventEmitter();
private config: Configuration = {
enable: true
enable: true,
assumeIsSvelteProject: false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dummdidumm looks great, thanks!

Just to double check, isConfigChanged in this class still only reacts to enable, is that alright?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's right. I implemented this way because assumeIsSvelteProject is the very first thing that is checked, and everything else is just skipped else, so no point in reacting to something that can never be reacted to you.

Is that a problem for the Intellij integration because you create the TypeScript service eagerly, and therefore all plugins eagerly, and what you need instead is some kind of "sleep" mode where things are already prepared but not turned on yet in the plugin? I imagine that being tricky, I don't know how TypeScript would react if we lazily patch stuff. Probably the closest to this is the enable flag which turns off all the intellisense-related work when it's false, so it's almost like the sleep mode I described.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second take your current code is fine. No, we create TypeScript service when the first TS file is opened and we control which commands are sent in what order. We never had to use "configurePlugin" before actually and my initial understanding was wrong, so I was getting undefined at creation time. After a bit of investigation and a bug fix in protocol handling, now it works as expected 👍

Type checks for Svelte compiled classes work without node_modules installed. Zero-effort types are not injected but after npm install everything refreshes properly.

Thanks again!

@dummdidumm dummdidumm merged commit 663e602 into master Oct 27, 2023
1 of 2 checks passed
@dummdidumm dummdidumm deleted the plugin-force-start branch October 27, 2023 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants