@@ -49,7 +49,7 @@ import {
4949 ICodeOverridesRegistry ,
5050 ILSPCodeOverridesManager
5151} from './overrides/tokens' ;
52- import { SettingsUIManager } from './settings' ;
52+ import { SettingsUIManager , SettingsSchemaManager } from './settings' ;
5353import {
5454 IAdapterTypeOptions ,
5555 ILSPAdapterManager ,
@@ -154,7 +154,7 @@ export class LSPExtension implements ILSPExtension {
154154 connection_manager : DocumentConnectionManager ;
155155 language_server_manager : LanguageServerManager ;
156156 feature_manager : ILSPFeatureManager ;
157- private _settingsUI : SettingsUIManager ;
157+ private _settingsSchemaManager : SettingsSchemaManager ;
158158
159159 constructor (
160160 public app : JupyterFrontEnd ,
@@ -201,42 +201,42 @@ export class LSPExtension implements ILSPExtension {
201201
202202 this . feature_manager = new FeatureManager ( ) ;
203203
204- this . _settingsUI = new SettingsUIManager ( {
204+ this . _settingsSchemaManager = new SettingsSchemaManager ( {
205205 settingRegistry : this . setting_registry ,
206- formRegistry : formRegistry ,
207- console : this . console . scope ( 'SettingsUIManager' ) ,
208206 languageServerManager : this . language_server_manager ,
209207 trans : trans ,
208+ console : this . console . scope ( 'SettingsSchemaManager' ) ,
210209 restored : app . restored
211210 } ) ;
212- this . _settingsUI
213- . setupSchemaForUI ( plugin . id )
211+
212+ if ( formRegistry != null ) {
213+ const settingsUI = new SettingsUIManager ( {
214+ settingRegistry : this . setting_registry ,
215+ console : this . console . scope ( 'SettingsUIManager' ) ,
216+ languageServerManager : this . language_server_manager ,
217+ trans : trans ,
218+ schemaValidated : this . _settingsSchemaManager . schemaValidated
219+ } ) ;
220+ // register custom UI field for `language_servers` property
221+ formRegistry . addRenderer (
222+ 'language_servers' ,
223+ settingsUI . renderForm . bind ( settingsUI )
224+ ) ;
225+ }
226+
227+ this . _settingsSchemaManager
228+ . setupSchemaTransform ( plugin . id )
214229 . then ( this . _activate . bind ( this ) )
215230 . catch ( this . _activate . bind ( this ) ) ;
216231 }
217232
218233 private _activate ( ) : void {
219234 this . setting_registry
220235 . load ( plugin . id )
221- . then ( settings => {
222- const options = this . _settingsUI . normalizeSettings (
223- settings . composite as Required < LanguageServer >
224- ) ;
225-
226- // Store the initial server settings, to be sent asynchronously
227- // when the servers are initialized.
228- const initial_configuration = ( options . language_servers ||
229- { } ) as TLanguageServerConfigurations ;
230- this . connection_manager . initial_configurations = initial_configuration ;
231- // update the server-independent part of configuration immediately
232- this . connection_manager . updateConfiguration ( initial_configuration ) ;
233- this . connection_manager . updateLogging (
234- options . logAllCommunication ,
235- options . setTrace
236- ) ;
237-
238- settings . changed . connect ( ( ) => {
239- this . updateOptions ( settings ) ;
236+ . then ( async settings => {
237+ await this . _updateOptions ( settings , false ) ;
238+ settings . changed . connect ( async ( ) => {
239+ await this . _updateOptions ( settings , true ) ;
240240 } ) ;
241241 } )
242242 . catch ( ( reason : Error ) => {
@@ -271,18 +271,28 @@ export class LSPExtension implements ILSPExtension {
271271 return this . code_overrides_manager . registry ;
272272 }
273273
274- private updateOptions ( settings : ISettingRegistry . ISettings ) {
275- const options = this . _settingsUI . normalizeSettings (
274+ private async _updateOptions (
275+ settings : ISettingRegistry . ISettings ,
276+ afterInitialization = false
277+ ) {
278+ const options = await this . _settingsSchemaManager . normalizeSettings (
276279 settings . composite as Required < LanguageServer >
277280 ) ;
278-
281+ // Store the initial server settings, to be sent asynchronously
282+ // when the servers are initialized.
279283 const languageServerSettings = ( options . language_servers ||
280284 { } ) as TLanguageServerConfigurations ;
281285
282286 this . connection_manager . initial_configurations = languageServerSettings ;
283287 // TODO: if priorities changed reset connections
288+
289+ // update the server-independent part of configuration immediately
284290 this . connection_manager . updateConfiguration ( languageServerSettings ) ;
285- this . connection_manager . updateServerConfigurations ( languageServerSettings ) ;
291+ if ( afterInitialization ) {
292+ this . connection_manager . updateServerConfigurations (
293+ languageServerSettings
294+ ) ;
295+ }
286296 this . connection_manager . updateLogging (
287297 options . logAllCommunication ,
288298 options . setTrace
0 commit comments