Skip to content

Commit

Permalink
Use app's HTTP settings, cherry-picked from jupyter-lsp/jupyterlab-ls…
Browse files Browse the repository at this point in the history
…p#882

Co-authored-by: Nicholas Bollweg <[email protected]>
  • Loading branch information
krassowski and bollwyvl committed Jun 18, 2023
1 parent 9780334 commit 5246f1d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/lsp-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down
6 changes: 3 additions & 3 deletions packages/lsp/src/connection_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -655,7 +654,8 @@ namespace Private {
): Promise<LSPConnection> {
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,
Expand Down
10 changes: 9 additions & 1 deletion packages/lsp/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ export class LanguageServerManager implements ILanguageServerManager {
get isEnabled(): boolean {
return this._enabled;
}

/**
* Check if the manager is disposed.
*/
get isDisposed(): boolean {
return this._isDisposed;
}

/**
* Get server connection settings.
*/
get settings() {
return this._settings;
}

/**
* Get the language server specs.
*/
Expand Down Expand Up @@ -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]);
}
Expand Down
7 changes: 7 additions & 0 deletions packages/lsp/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ export interface ILanguageServerManager extends IDisposable {
*/
readonly sessions: TSessionMap;

/**
* @alpha
*
* Get server connection settings.
*/
readonly settings: ServerConnection.ISettings;

/**
* @alpha
*
Expand Down

0 comments on commit 5246f1d

Please sign in to comment.