@@ -91,10 +91,6 @@ export function activate(context: ExtensionContext) {
9191 "rescript" ,
9292 ) ;
9393
94- const useExperimentalServer = workspace
95- . getConfiguration ( "rescript" )
96- . get < boolean > ( "useExperimentalServer" , false ) ;
97-
9894 function createExperimentalLanguageClient ( ) {
9995 const binaryPathFromNodeModules = Uri . joinPath (
10096 context . extensionUri ,
@@ -133,36 +129,11 @@ export function activate(context: ExtensionContext) {
133129
134130 const client = new LanguageClient (
135131 "ReScriptLSP" ,
136- "ReScript Experimental Language Server" ,
132+ "Experimental ReScript Language Server" ,
137133 serverOptions ,
138134 clientOptions ,
139135 ) ;
140136
141- // This sets up a listener that, if we're in code analysis mode, triggers
142- // code analysis as the LS server reports that ReScript compilation has
143- // finished. This is needed because code analysis must wait until
144- // compilation has finished, and the most reliable source for that is the LS
145- // server, that already keeps track of when the compiler finishes in order to
146- // other provide fresh diagnostics.
147- context . subscriptions . push (
148- client . onDidChangeState ( ( { newState } ) => {
149- if ( newState === State . Running ) {
150- context . subscriptions . push (
151- client . onNotification ( "rescript/compilationFinished" , ( ) => {
152- if ( inCodeAnalysisState . active === true ) {
153- customCommands . codeAnalysisWithReanalyze (
154- diagnosticsCollection ,
155- diagnosticsResultCodeActions ,
156- outputChannel ,
157- codeAnalysisRunningStatusBarItem ,
158- ) ;
159- }
160- } ) ,
161- ) ;
162- }
163- } ) ,
164- ) ;
165-
166137 return client ;
167138 }
168139
@@ -219,38 +190,46 @@ export function activate(context: ExtensionContext) {
219190 clientOptions ,
220191 ) ;
221192
222- // This sets up a listener that, if we're in code analysis mode, triggers
223- // code analysis as the LS server reports that ReScript compilation has
224- // finished. This is needed because code analysis must wait until
225- // compilation has finished, and the most reliable source for that is the LS
226- // server, that already keeps track of when the compiler finishes in order to
227- // other provide fresh diagnostics.
228- context . subscriptions . push (
229- client . onDidChangeState ( ( { newState } ) => {
230- if ( newState === State . Running ) {
231- context . subscriptions . push (
232- client . onNotification ( "rescript/compilationFinished" , ( ) => {
233- if ( inCodeAnalysisState . active === true ) {
234- customCommands . codeAnalysisWithReanalyze (
235- diagnosticsCollection ,
236- diagnosticsResultCodeActions ,
237- outputChannel ,
238- codeAnalysisRunningStatusBarItem ,
239- ) ;
240- }
241- } ) ,
242- ) ;
243- }
244- } ) ,
245- ) ;
246-
247193 return client ;
248194 }
249195
196+ function createClient ( ) {
197+ const useExperimentalServer = workspace
198+ . getConfiguration ( "rescript" )
199+ . get < boolean > ( "useExperimentalServer" , false ) ;
200+
201+ return useExperimentalServer
202+ ? createExperimentalLanguageClient ( )
203+ : createLanguageClient ( ) ;
204+ }
205+
250206 // Create the language client and start the client.
251- client = useExperimentalServer
252- ? createExperimentalLanguageClient ( )
253- : createLanguageClient ( ) ;
207+ client = createClient ( ) ;
208+
209+ // This sets up a listener that, if we're in code analysis mode, triggers
210+ // code analysis as the LS server reports that ReScript compilation has
211+ // finished. This is needed because code analysis must wait until
212+ // compilation has finished, and the most reliable source for that is the LS
213+ // server, that already keeps track of when the compiler finishes in order to
214+ // other provide fresh diagnostics.
215+ context . subscriptions . push (
216+ client . onDidChangeState ( ( { newState } ) => {
217+ if ( newState === State . Running ) {
218+ context . subscriptions . push (
219+ client . onNotification ( "rescript/compilationFinished" , ( ) => {
220+ if ( inCodeAnalysisState . active === true ) {
221+ customCommands . codeAnalysisWithReanalyze (
222+ diagnosticsCollection ,
223+ diagnosticsResultCodeActions ,
224+ outputChannel ,
225+ codeAnalysisRunningStatusBarItem ,
226+ ) ;
227+ }
228+ } ) ,
229+ ) ;
230+ }
231+ } ) ,
232+ ) ;
254233
255234 // Create a custom diagnostics collection, for cases where we want to report
256235 // diagnostics programatically from inside of the extension. The reason this
@@ -591,9 +570,7 @@ export function activate(context: ExtensionContext) {
591570
592571 commands . registerCommand ( "rescript-vscode.restart_language_server" , ( ) => {
593572 client . stop ( ) . then ( ( ) => {
594- client = useExperimentalServer
595- ? createExperimentalLanguageClient ( )
596- : createLanguageClient ( ) ;
573+ client = createClient ( ) ;
597574 client . start ( ) ;
598575 } ) ;
599576 } ) ;
@@ -628,8 +605,6 @@ export function activate(context: ExtensionContext) {
628605 }
629606 // Send a general message that configuration has updated. Clients
630607 // interested can then pull the new configuration as they see fit.
631- // The spec say params DidChangeConfigurationParams can contain the settings fields
632- // https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#didChangeConfigurationParams
633608 client
634609 . sendNotification ( DidChangeConfigurationNotification . type , {
635610 settings : null ,
0 commit comments