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:
Matt Bierner
2018-12-13 14:29:20 -08:00
parent 3a0be84974
commit 6b89247875
3 changed files with 12 additions and 2 deletions

View File

@@ -16,6 +16,11 @@
"name": { "name": {
"type": "string", "type": "string",
"description": "Name of the plugin as listed in the package.json." "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?"
} }
} }
} }

View File

@@ -113,8 +113,11 @@ export class TypeScriptServerSpawner {
if (pluginManager.plugins.length) { if (pluginManager.plugins.length) {
args.push('--globalPlugins', pluginManager.plugins.map(x => x.name).join(',')); args.push('--globalPlugins', pluginManager.plugins.map(x => x.name).join(','));
if (currentVersion.path === this._versionProvider.defaultVersion.path) { const isUsingBundledTypeScriptVersion = currentVersion.path === this._versionProvider.defaultVersion.path;
pluginPaths.push(...pluginManager.plugins.map(x => x.path)); for (const plugin of pluginManager.plugins) {
if (isUsingBundledTypeScriptVersion || plugin.enableForWorkspaceTypeScriptVersions) {
pluginPaths.push(plugin.path);
}
} }
} }

View File

@@ -10,6 +10,7 @@ import { memoize } from './memoize';
export interface TypeScriptServerPlugin { export interface TypeScriptServerPlugin {
readonly path: string; readonly path: string;
readonly name: string; readonly name: string;
readonly enableForWorkspaceTypeScriptVersions: boolean;
readonly languages: ReadonlyArray<string>; readonly languages: ReadonlyArray<string>;
} }
@@ -25,6 +26,7 @@ export class PluginManager extends Disposable {
for (const plugin of pack.contributes.typescriptServerPlugins) { for (const plugin of pack.contributes.typescriptServerPlugins) {
plugins.push({ plugins.push({
name: plugin.name, name: plugin.name,
enableForWorkspaceTypeScriptVersions: !!plugin.enableForWorkspaceTypeScriptVersions,
path: extension.extensionPath, path: extension.extensionPath,
languages: Array.isArray(plugin.languages) ? plugin.languages : [], languages: Array.isArray(plugin.languages) ? plugin.languages : [],
}); });