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

refactor(language-server): isolate TS dependency for Server and ServerProjectProviderFactory #140

Merged
merged 2 commits into from Feb 23, 2024

Conversation

johnsoncodehk
Copy link
Member

  • The following options have been removed from the Server InitializationOptions interface:

    • typescript#tsdk
    • typescript#tsdkUrl
    • ignoreTriggerCharacters
  • createSimpleProjectProvider has been renamed to createSimpleProjectProviderFactory and needs to be invoked with no arguments.

  • createTypeScriptProjectProvider has been renamed to createTypeScriptProjectProviderFactory and needs to be invoked with a TS module as an argument.

  • The core code of @volar/language-server no longer loads TSDK with server.initialize(), so you now need to manually load TSDK. Here is an example from Vue Language Tools:

     import { loadTsdkByPath } from '@volar/language-server/node';
    
     connection.onInitialize(params => {
     	const tsdk = loadTsdkByPath(params.initializationOptions.typescript.tsdk, params.locale);
     	return server.initialize(
     		params,
     		params.initializationOptions?.hybridMode
     			? createSimpleProjectProviderFactory()
     			: createTypeScriptProjectProviderFactory(tsdk.typescript, tsdk.diagnosticMessages),
     		{ /* ... */ },
     	);
     });
  • There are also some internal code adjustments that people shouldn't need to be concerned about.

@johnsoncodehk johnsoncodehk changed the title refactor(language-server): isolate TS dependency for Server and Se rProjectProviderFactory refactor(language-server): isolate TS dependency for Server and ServerProjectProviderFactory Feb 23, 2024
@johnsoncodehk johnsoncodehk merged commit fe7f795 into master Feb 23, 2024
6 checks passed
@johnsoncodehk johnsoncodehk deleted the language-server-simplify branch February 23, 2024 16:21
remcohaszing added a commit that referenced this pull request Feb 26, 2024
This allows people to load TypeScript as suggested in #140. Since
`initializationOptions` is of type `any` there, it doesn’t really
matter. But the `InitializationOptions` interface is used by the test
utils and prohibits the user from passing additional properties.

Also it’s nice if all Volar based language servers that do allow the
client to pass the TypeScript SDK, do so in a consistent manner.
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.

None yet

1 participant