Allow extension contributed TS plugins to be loaded for workspace versions of TS
Fixes #65031 Adds a `enableForWorkspaceTypeScriptVersions` flag (default false) to the plugins contributions that allows a contributed plugin to be loaded for workspace versions of ts
This commit is contained in:
parent
3a0be84974
commit
6b89247875
|
@ -16,6 +16,11 @@
|
|||
"name": {
|
||||
"type": "string",
|
||||
"description": "Name of the plugin as listed in the package.json."
|
||||
},
|
||||
"enableForWorkspaceTypeScriptVersions": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Should the plugin be loaded when using workspace versions of TypeScript?"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,8 +113,11 @@ export class TypeScriptServerSpawner {
|
|||
if (pluginManager.plugins.length) {
|
||||
args.push('--globalPlugins', pluginManager.plugins.map(x => x.name).join(','));
|
||||
|
||||
if (currentVersion.path === this._versionProvider.defaultVersion.path) {
|
||||
pluginPaths.push(...pluginManager.plugins.map(x => x.path));
|
||||
const isUsingBundledTypeScriptVersion = currentVersion.path === this._versionProvider.defaultVersion.path;
|
||||
for (const plugin of pluginManager.plugins) {
|
||||
if (isUsingBundledTypeScriptVersion || plugin.enableForWorkspaceTypeScriptVersions) {
|
||||
pluginPaths.push(plugin.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import { memoize } from './memoize';
|
|||
export interface TypeScriptServerPlugin {
|
||||
readonly path: string;
|
||||
readonly name: string;
|
||||
readonly enableForWorkspaceTypeScriptVersions: boolean;
|
||||
readonly languages: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
|
@ -25,6 +26,7 @@ export class PluginManager extends Disposable {
|
|||
for (const plugin of pack.contributes.typescriptServerPlugins) {
|
||||
plugins.push({
|
||||
name: plugin.name,
|
||||
enableForWorkspaceTypeScriptVersions: !!plugin.enableForWorkspaceTypeScriptVersions,
|
||||
path: extension.extensionPath,
|
||||
languages: Array.isArray(plugin.languages) ? plugin.languages : [],
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue