@@ -252,26 +252,26 @@ export async function findHaskellLanguageServer(
252
252
253
253
// get a preliminary toolchain for finding the correct project GHC version (we need HLS and cabal/stack and ghc as fallback),
254
254
// later we may install a different toolchain that's more project-specific
255
- const installGHC = ! executableExists ( 'ghc' ) ;
256
- let latestHLS = await getLatestToolFromGHCup ( context , logger , 'hls' ) ;
257
- let latestCabal = await getLatestToolFromGHCup ( context , logger , 'cabal' ) ;
258
- let latestStack = await getLatestToolFromGHCup ( context , logger , 'stack' ) ;
259
- let recGHC = await getLatestAvailableToolFromGHCup ( context , logger , 'ghc' , 'recommended' ) ;
260
- // TODO: this should be obsolete for ghcup-0.1.17.6
261
- // and we can drop the use of `-b`.
262
- let symHLSPath = installGHC
263
- ? path . join ( storagePath , `hls-${ latestHLS } _cabal-${ latestCabal } -stack-${ latestStack } ` )
264
- : path . join ( storagePath , `hls-${ latestHLS } _ghc-${ recGHC } -cabal-${ latestCabal } -stack-${ latestStack } ` ) ;
255
+ let latestHLS = await getLatestToolFromGHCup ( context , logger , 'hls' ) ;
256
+ let latestCabal = ( workspace . getConfiguration ( 'haskell' ) . get ( 'installCabal' ) as boolean )
257
+ ? await getLatestToolFromGHCup ( context , logger , 'cabal' )
258
+ : null ;
259
+ let latestStack = ( workspace . getConfiguration ( 'haskell' ) . get ( 'installStack' ) as boolean )
260
+ ? await getLatestToolFromGHCup ( context , logger , 'stack' )
261
+ : null ;
262
+ let recGHC =
263
+ ! executableExists ( 'ghc' ) && ( workspace . getConfiguration ( 'haskell' ) . get ( 'installGHC' ) as boolean )
264
+ ? await getLatestAvailableToolFromGHCup ( context , logger , 'ghc' , 'recommended' )
265
+ : null ;
265
266
266
267
const latestToolchainBindir = await callGHCup (
267
268
context ,
268
269
logger ,
269
270
[ 'run'
270
- , '--hls' , latestHLS ? latestHLS : 'latest'
271
- , '--cabal' , latestCabal ? latestCabal : 'latest'
272
- , '--stack' , latestStack ? latestStack : 'latest'
273
- , ...( installGHC ? [ '--ghc' , 'recommended' ] : [ ] )
274
- , '-b' , symHLSPath
271
+ , '--hls' , latestHLS
272
+ , ...( latestCabal ? [ '--cabal' , latestCabal ] : [ ] )
273
+ , ...( latestStack ? [ '--stack' , latestStack ] : [ ] )
274
+ , ...( recGHC ? [ '--ghc' , 'recommended' ] : [ ] )
275
275
, '--install'
276
276
] ,
277
277
'Installing latest toolchain for bootstrap' ,
@@ -286,32 +286,22 @@ export async function findHaskellLanguageServer(
286
286
const [ installableHls , projectGhc ] = await getLatestHLS ( context , logger , workingDir , latestToolchainBindir ) ;
287
287
288
288
latestHLS = await getLatestToolFromGHCup ( context , logger , 'hls' )
289
- latestCabal = await getLatestToolFromGHCup ( context , logger , 'cabal' ) ;
290
- latestStack = await getLatestToolFromGHCup ( context , logger , 'stack' ) ;
289
+ latestCabal = latestCabal ? await getLatestToolFromGHCup ( context , logger , 'cabal' ) : null ;
290
+ latestStack = latestStack ? await getLatestToolFromGHCup ( context , logger , 'stack' ) : null ;
291
291
292
292
// now install said version in an isolated symlink directory
293
-
294
- // TODO: this should be obsolete for ghcup-0.1.17.6
295
- // and we can drop the use of `-b`.
296
- symHLSPath = path . join ( storagePath , `hls-${ installableHls } _ghc-${ projectGhc } _cabal-${ latestCabal } _stack-${ latestStack } ` ) ;
297
-
298
- const wrapper = path . join ( symHLSPath , `haskell-language-server-wrapper${ exeExt } ` ) ;
299
- // Check if we have a working symlink, so we can avoid another popup
300
- if ( ! fs . existsSync ( wrapper ) ) {
301
- await callGHCup (
302
- context ,
303
- logger ,
304
- [ 'run'
305
- , '--hls' , installableHls
306
- , '--ghc' , projectGhc
307
- , '--cabal' , `${ latestCabal } `
308
- , '--stack' , `${ latestStack } `
309
- , '-b' , symHLSPath , '-i' ] ,
310
- `Installing project specific toolchain: HLS-${ installableHls } , GHC-${ projectGhc } , cabal-${ latestCabal } , stack-${ latestStack } ` ,
311
- true
312
- ) ;
313
- }
314
- return wrapper ;
293
+ await callGHCup (
294
+ context ,
295
+ logger ,
296
+ [ 'run'
297
+ , '--hls' , installableHls
298
+ , ...( latestCabal ? [ '--cabal' , latestCabal ] : [ ] )
299
+ , ...( latestStack ? [ '--stack' , latestStack ] : [ ] )
300
+ , ...( ( workspace . getConfiguration ( 'haskell' ) . get ( 'installGHC' ) as boolean ) ? [ '--ghc' , projectGhc ] : [ ] )
301
+ , '--install' ] ,
302
+ `Installing project specific toolchain: HLS-${ installableHls } , GHC-${ projectGhc } , cabal-${ latestCabal } , stack-${ latestStack } ` ,
303
+ true
304
+ ) ;
315
305
}
316
306
}
317
307
0 commit comments