@@ -266,40 +266,42 @@ export async function findHaskellLanguageServer(
266
266
latestStack = await getLatestToolFromGHCup ( context , logger , 'stack' ) ;
267
267
}
268
268
if ( recGHC === undefined ) {
269
- recGHC = ! ( executableExists ( 'ghc' ) )
269
+ recGHC = ! executableExists ( 'ghc' )
270
270
? await getLatestAvailableToolFromGHCup ( context , logger , 'ghc' , 'recommended' )
271
271
: null ;
272
272
}
273
273
274
274
// download popups
275
275
const promptBeforeDownloads = workspace . getConfiguration ( 'haskell' ) . get ( 'promptBeforeDownloads' ) as boolean ;
276
276
if ( promptBeforeDownloads ) {
277
- const hlsInstalled = latestHLS
278
- ? await toolInstalled ( context , logger , 'hls' , latestHLS )
279
- : undefined ;
280
- const cabalInstalled = latestCabal
281
- ? await toolInstalled ( context , logger , 'cabal' , latestCabal )
282
- : undefined ;
283
- const stackInstalled = latestStack
284
- ? await toolInstalled ( context , logger , 'stack' , latestStack )
285
- : undefined ;
277
+ const hlsInstalled = latestHLS ? await toolInstalled ( context , logger , 'hls' , latestHLS ) : undefined ;
278
+ const cabalInstalled = latestCabal ? await toolInstalled ( context , logger , 'cabal' , latestCabal ) : undefined ;
279
+ const stackInstalled = latestStack ? await toolInstalled ( context , logger , 'stack' , latestStack ) : undefined ;
286
280
const ghcInstalled = executableExists ( 'ghc' )
287
- ? new InstalledTool ( 'ghc' , await callAsync ( `ghc${ exeExt } ` , [ '--numeric-version' ] , logger , undefined , undefined , false ) )
288
- // if recGHC is null, that means user disabled automatic handling,
289
- : ( recGHC !== null ? await toolInstalled ( context , logger , 'ghc' , recGHC ) : undefined ) ;
290
- const toInstall : InstalledTool [ ] = [ hlsInstalled , cabalInstalled , stackInstalled , ghcInstalled ]
291
- . filter ( ( tool ) => tool && ! tool . installed ) as InstalledTool [ ] ;
281
+ ? new InstalledTool (
282
+ 'ghc' ,
283
+ await callAsync ( `ghc${ exeExt } ` , [ '--numeric-version' ] , logger , undefined , undefined , false )
284
+ )
285
+ : // if recGHC is null, that means user disabled automatic handling,
286
+ recGHC !== null
287
+ ? await toolInstalled ( context , logger , 'ghc' , recGHC )
288
+ : undefined ;
289
+ const toInstall : InstalledTool [ ] = [ hlsInstalled , cabalInstalled , stackInstalled , ghcInstalled ] . filter (
290
+ ( tool ) => tool && ! tool . installed
291
+ ) as InstalledTool [ ] ;
292
292
if ( toInstall . length > 0 ) {
293
293
const decision = await window . showInformationMessage (
294
- `Need to download ${ toInstall . map ( t => t . nameWithVersion ) . join ( ', ' ) } , continue?` ,
294
+ `Need to download ${ toInstall . map ( ( t ) => t . nameWithVersion ) . join ( ', ' ) } , continue?` ,
295
295
'Yes' ,
296
296
'No' ,
297
297
"Yes, don't ask again"
298
298
) ;
299
299
if ( decision === 'Yes' ) {
300
- logger . info ( `User accepted download for ${ toInstall . map ( t => t . nameWithVersion ) . join ( ', ' ) } .` ) ;
300
+ logger . info ( `User accepted download for ${ toInstall . map ( ( t ) => t . nameWithVersion ) . join ( ', ' ) } .` ) ;
301
301
} else if ( decision === "Yes, don't ask again" ) {
302
- logger . info ( `User accepted download for ${ toInstall . map ( t => t . nameWithVersion ) . join ( ', ' ) } and won't be asked again.` ) ;
302
+ logger . info (
303
+ `User accepted download for ${ toInstall . map ( ( t ) => t . nameWithVersion ) . join ( ', ' ) } and won't be asked again.`
304
+ ) ;
303
305
workspace . getConfiguration ( 'haskell' ) . update ( 'promptBeforeDownloads' , false ) ;
304
306
} else {
305
307
toInstall . forEach ( ( tool ) => {
@@ -352,26 +354,25 @@ export async function findHaskellLanguageServer(
352
354
353
355
// more download popups
354
356
if ( promptBeforeDownloads ) {
355
- const hlsInstalled = projectHls
356
- ? await toolInstalled ( context , logger , 'hls' , projectHls )
357
- : undefined ;
358
- const ghcInstalled = projectGhc
359
- ? await toolInstalled ( context , logger , 'ghc' , projectGhc )
360
- : undefined ;
361
- const toInstall : InstalledTool [ ] = [ hlsInstalled , ghcInstalled ]
362
- . filter ( ( tool ) => tool && ! tool . installed ) as InstalledTool [ ] ;
357
+ const hlsInstalled = projectHls ? await toolInstalled ( context , logger , 'hls' , projectHls ) : undefined ;
358
+ const ghcInstalled = projectGhc ? await toolInstalled ( context , logger , 'ghc' , projectGhc ) : undefined ;
359
+ const toInstall : InstalledTool [ ] = [ hlsInstalled , ghcInstalled ] . filter (
360
+ ( tool ) => tool && ! tool . installed
361
+ ) as InstalledTool [ ] ;
363
362
if ( toInstall . length > 0 ) {
364
363
const decision = await window . showInformationMessage (
365
- `Need to download ${ toInstall . map ( t => t . nameWithVersion ) . join ( ', ' ) } , continue?` ,
364
+ `Need to download ${ toInstall . map ( ( t ) => t . nameWithVersion ) . join ( ', ' ) } , continue?` ,
366
365
{ modal : true } ,
367
366
'Yes' ,
368
367
'No' ,
369
368
"Yes, don't ask again"
370
369
) ;
371
370
if ( decision === 'Yes' ) {
372
- logger . info ( `User accepted download for ${ toInstall . map ( t => t . nameWithVersion ) . join ( ', ' ) } .` ) ;
371
+ logger . info ( `User accepted download for ${ toInstall . map ( ( t ) => t . nameWithVersion ) . join ( ', ' ) } .` ) ;
373
372
} else if ( decision === "Yes, don't ask again" ) {
374
- logger . info ( `User accepted download for ${ toInstall . map ( t => t . nameWithVersion ) . join ( ', ' ) } and won't be asked again.` ) ;
373
+ logger . info (
374
+ `User accepted download for ${ toInstall . map ( ( t ) => t . nameWithVersion ) . join ( ', ' ) } and won't be asked again.`
375
+ ) ;
375
376
workspace . getConfiguration ( 'haskell' ) . update ( 'promptBeforeDownloads' , false ) ;
376
377
} else {
377
378
toInstall . forEach ( ( tool ) => {
@@ -399,7 +400,15 @@ export async function findHaskellLanguageServer(
399
400
...( projectGhc ? [ '--ghc' , projectGhc ] : [ ] ) ,
400
401
'--install' ,
401
402
] ,
402
- `Installing project specific toolchain: ${ [ [ 'hls' , projectHls ] , [ 'GHC' , projectGhc ] , [ 'cabal' , latestCabal ] , [ 'stack' , latestStack ] ] . filter ( t => t [ 1 ] ) . map ( t => `${ t [ 0 ] } -${ t [ 1 ] } ` ) . join ( ', ' ) } ` ,
403
+ `Installing project specific toolchain: ${ [
404
+ [ 'hls' , projectHls ] ,
405
+ [ 'GHC' , projectGhc ] ,
406
+ [ 'cabal' , latestCabal ] ,
407
+ [ 'stack' , latestStack ] ,
408
+ ]
409
+ . filter ( ( t ) => t [ 1 ] )
410
+ . map ( ( t ) => `${ t [ 0 ] } -${ t [ 1 ] } ` )
411
+ . join ( ', ' ) } `,
403
412
true
404
413
) ;
405
414
0 commit comments