diff --git a/packages/lsp-extension/src/index.ts b/packages/lsp-extension/src/index.ts index b8755c67a549..8a5a3e18d4a3 100644 --- a/packages/lsp-extension/src/index.ts +++ b/packages/lsp-extension/src/index.ts @@ -94,7 +94,9 @@ function activate( settingRendererRegistry: IFormRendererRegistry | null ): ILSPDocumentConnectionManager { const LANGUAGE_SERVERS = 'languageServers'; - const languageServerManager = new LanguageServerManager({}); + const languageServerManager = new LanguageServerManager({ + settings: app.serviceManager.serverSettings + }); const connectionManager = new DocumentConnectionManager({ languageServerManager }); diff --git a/packages/lsp/src/connection_manager.ts b/packages/lsp/src/connection_manager.ts index b035a7f0bd32..cd1f684a117a 100644 --- a/packages/lsp/src/connection_manager.ts +++ b/packages/lsp/src/connection_manager.ts @@ -2,7 +2,6 @@ // Distributed under the terms of the Modified BSD License. import { PageConfig, URLExt } from '@jupyterlab/coreutils'; -import { ServerConnection } from '@jupyterlab/services'; import { IDocumentWidget } from '@jupyterlab/docregistry'; import { ISignal, Signal } from '@lumino/signaling'; @@ -548,7 +547,7 @@ export namespace DocumentConnectionManager { virtualDocument: VirtualDocument, language: string ): IURIs | undefined { - const settings = ServerConnection.makeSettings(); + const { settings } = Private.getLanguageServerManager(); const wsBase = settings.wsUrl; const rootUri = PageConfig.getOption('rootUri'); const virtualDocumentsUri = PageConfig.getOption('virtualDocumentsUri'); @@ -655,7 +654,8 @@ namespace Private { ): Promise { let connection = _connections.get(languageServerId); if (!connection) { - const socket = new WebSocket(uris.socket); + const { settings } = Private.getLanguageServerManager(); + const socket = new settings.WebSocket(uris.socket); const connection = new LSPConnection({ languageId: language, serverUri: uris.server, diff --git a/packages/lsp/src/manager.ts b/packages/lsp/src/manager.ts index 500f8a062d6d..f988da06c92a 100644 --- a/packages/lsp/src/manager.ts +++ b/packages/lsp/src/manager.ts @@ -33,6 +33,7 @@ export class LanguageServerManager implements ILanguageServerManager { get isEnabled(): boolean { return this._enabled; } + /** * Check if the manager is disposed. */ @@ -40,6 +41,13 @@ export class LanguageServerManager implements ILanguageServerManager { return this._isDisposed; } + /** + * Get server connection settings. + */ + get settings() { + return this._settings; + } + /** * Get the language server specs. */ @@ -204,7 +212,7 @@ export class LanguageServerManager implements ILanguageServerManager { for (let key of Object.keys(sessions)) { let id: TLanguageServerId = key as TLanguageServerId; if (this._sessions.has(id)) { - Object.assign(this._sessions.get(id)!, sessions[key]); + Object.assign(this._sessions.get(id) || {}, sessions[key]); } else { this._sessions.set(id, sessions[key]); } diff --git a/packages/lsp/src/tokens.ts b/packages/lsp/src/tokens.ts index 2b25bb4e7a0a..0bff468a212b 100644 --- a/packages/lsp/src/tokens.ts +++ b/packages/lsp/src/tokens.ts @@ -91,6 +91,13 @@ export interface ILanguageServerManager extends IDisposable { */ readonly sessions: TSessionMap; + /** + * @alpha + * + * Get server connection settings. + */ + readonly settings: ServerConnection.ISettings; + /** * @alpha *