Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

import { noop } from 'lodash';
import { Uri, Event } from 'vscode';
import { BaseLanguageClient } from 'vscode-languageclient';
import { BaseLanguageClient, LanguageClientOptions } from 'vscode-languageclient';
import { LanguageClient } from 'vscode-languageclient/node';
import { PYLANCE_NAME } from './activation/node/languageClientFactory';
import { ILanguageServerOutputChannel } from './activation/types';
import { IExtensionApi } from './apiTypes';
import { isTestExecution, PYTHON_LANGUAGE } from './common/constants';
import { IConfigurationService, Resource } from './common/types';
Expand All @@ -28,6 +29,8 @@ export function buildApi(
serviceManager.addSingleton<JupyterExtensionIntegration>(JupyterExtensionIntegration, JupyterExtensionIntegration);
const jupyterIntegration = serviceContainer.get<JupyterExtensionIntegration>(JupyterExtensionIntegration);
const envService = serviceContainer.get<IEnvironmentVariablesProvider>(IEnvironmentVariablesProvider);
const outputChannel = serviceContainer.get<ILanguageServerOutputChannel>(ILanguageServerOutputChannel);

const api: IExtensionApi & {
/**
* @deprecated Temporarily exposed for Pylance until we expose this API generally. Will be removed in an
Expand Down Expand Up @@ -89,8 +92,14 @@ export function buildApi(
return envs.PYTHONPATH;
},
onDidEnvironmentVariablesChange: envService.onDidEnvironmentVariablesChange,
createClient: (...args: any[]): BaseLanguageClient =>
new LanguageClient(PYTHON_LANGUAGE, PYLANCE_NAME, args[0], args[1]),
createClient: (...args: any[]): BaseLanguageClient => {
// Make sure we share output channel so that we can share one with
// Jedi as well.
const clientOptions = args[1] as LanguageClientOptions;
clientOptions.outputChannel = clientOptions.outputChannel ?? outputChannel.channel;

return new LanguageClient(PYTHON_LANGUAGE, PYLANCE_NAME, args[0], clientOptions);
},
start: (client: BaseLanguageClient): Promise<void> => client.start(),
stop: (client: BaseLanguageClient): Promise<void> => client.stop(),
},
Expand Down