Skip to content

Commit 6c07869

Browse files
committed
Fix order of config initialization
1 parent 95684ac commit 6c07869

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

packages/jupyterlab-lsp/src/connection_manager.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,28 @@ export class DocumentConnectionManager {
162162
}
163163

164164
/**
165-
* Currently only supports the settings that the language servers
166-
* accept using onDidChangeConfiguration messages, under the
167-
* "serverSettings" keyword in the setting registry. New keywords can
168-
* be added and extra functionality implemented here when needed.
165+
* Handles the settings that do not require an existing connection
166+
* with a language server (or can influence to which server the
167+
* connection will be created, e.g. `priority`).
168+
*
169+
* This function should be called **before** initialization of servers.
170+
*/
171+
public updateConfiguration(allServerSettings: TLanguageServerConfigurations) {
172+
this.language_server_manager.setConfiguration(allServerSettings);
173+
}
174+
175+
/**
176+
* Handles the settings that the language servers accept using
177+
* `onDidChangeConfiguration` messages, which should be passed under
178+
* the "serverSettings" keyword in the setting registry.
179+
* Other configuration options are handled by `updateConfiguration` instead.
180+
*
181+
* This function should be called **after** initialization of servers.
169182
*/
170183
public updateServerConfigurations(
171184
allServerSettings: TLanguageServerConfigurations
172185
) {
173186
let language_server_id: TServerKeys;
174-
this.language_server_manager.setConfiguration(allServerSettings);
175187

176188
for (language_server_id in allServerSettings) {
177189
if (!allServerSettings.hasOwnProperty(language_server_id)) {

packages/jupyterlab-lsp/src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,11 @@ export class LSPExtension implements ILSPExtension {
179179
.then(settings => {
180180
// Store the initial server settings, to be sent asynchronously
181181
// when the servers are initialized.
182-
this.connection_manager.initial_configurations = (settings.composite
183-
.language_servers || {}) as TLanguageServerConfigurations;
182+
const initial_configuration = (settings.composite.language_servers ||
183+
{}) as TLanguageServerConfigurations;
184+
this.connection_manager.initial_configurations = initial_configuration;
185+
// update the server-independent part of configuration immediately
186+
this.connection_manager.updateConfiguration(initial_configuration);
184187

185188
settings.changed.connect(() => {
186189
this.updateOptions(settings);
@@ -223,6 +226,10 @@ export class LSPExtension implements ILSPExtension {
223226

224227
const languageServerSettings = (options.language_servers ||
225228
{}) as TLanguageServerConfigurations;
229+
230+
this.connection_manager.initial_configurations = languageServerSettings;
231+
// TODO: if priorities changed reset connections
232+
this.connection_manager.updateConfiguration(languageServerSettings);
226233
this.connection_manager.updateServerConfigurations(languageServerSettings);
227234
}
228235
}

0 commit comments

Comments
 (0)