@@ -39,7 +39,7 @@ export class MissingToolError extends Error {
39
39
public readonly tool : string ;
40
40
constructor ( tool : string ) {
41
41
let prettyTool : string ;
42
- switch ( tool ) {
42
+ switch ( tool . toLowerCase ( ) ) {
43
43
case 'stack' :
44
44
prettyTool = 'Stack' ;
45
45
break ;
@@ -52,6 +52,12 @@ export class MissingToolError extends Error {
52
52
case 'ghcup' :
53
53
prettyTool = 'GHCup' ;
54
54
break ;
55
+ case 'haskell-language-server' :
56
+ prettyTool = 'HLS' ;
57
+ break ;
58
+ case 'hls' :
59
+ prettyTool = 'HLS' ;
60
+ break ;
55
61
default :
56
62
prettyTool = tool ;
57
63
break ;
@@ -66,6 +72,7 @@ export class MissingToolError extends Error {
66
72
return Uri . parse ( 'https://docs.haskellstack.org/en/stable/install_and_upgrade/' ) ;
67
73
case 'GHCup' :
68
74
case 'Cabal' :
75
+ case 'HLS' :
69
76
case 'GHC' :
70
77
return Uri . parse ( 'https://www.haskell.org/ghcup/' ) ;
71
78
default :
@@ -109,8 +116,7 @@ async function callAsync(
109
116
let newEnv : IEnvVars = await resolveServerEnvironmentPATH (
110
117
workspace . getConfiguration ( 'haskell' ) . get ( 'serverEnvironment' ) || { }
111
118
) ;
112
- newEnv = { ...( process . env as IEnvVars ) , ...newEnv } ;
113
- newEnv = { ...newEnv , ...( envAdd || { } ) } ;
119
+ newEnv = { ...( process . env as IEnvVars ) , ...newEnv , ...( envAdd || { } ) } ;
114
120
return window . withProgress (
115
121
{
116
122
location : ProgressLocation . Notification ,
@@ -120,7 +126,7 @@ async function callAsync(
120
126
async ( _ , token ) => {
121
127
return new Promise < string > ( ( resolve , reject ) => {
122
128
const command : string = binary + ' ' + args . join ( ' ' ) ;
123
- logger . info ( `Executing '${ command } ' in cwd '${ dir } '` ) ;
129
+ logger . info ( `Executing '${ command } ' in cwd '${ dir ? dir : process . cwd ( ) } '` ) ;
124
130
token . onCancellationRequested ( ( ) => {
125
131
logger . warn ( `User canceled the execution of '${ command } '` ) ;
126
132
} ) ;
@@ -197,9 +203,7 @@ async function findHLSinPATH(context: ExtensionContext, logger: Logger, folder?:
197
203
return exe ;
198
204
}
199
205
}
200
- const msg =
201
- 'Could not find a HLS binary in PATH! Consider installing HLS via ghcup or change "haskell.manageHLS" in your settings.' ;
202
- throw new Error ( msg ) ;
206
+ throw new MissingToolError ( 'hls' ) ;
203
207
}
204
208
205
209
/**
@@ -238,10 +242,10 @@ export async function findHaskellLanguageServer(
238
242
const promptMessage = 'How do you want the extension to manage/discover HLS and the relevant toolchain?' ;
239
243
240
244
const decision =
241
- ( await window . showInformationMessage ( promptMessage , 'automatically via GHCup' , 'manually via PATH' ) ) || null ;
242
- if ( decision === 'automatically via GHCup' ) {
245
+ ( await window . showInformationMessage ( promptMessage , 'Automatically via GHCup' , 'Manually via PATH' ) ) || null ;
246
+ if ( decision === 'Automatically via GHCup' ) {
243
247
manageHLS = 'GHCup' ;
244
- } else if ( decision === 'manually via PATH' ) {
248
+ } else if ( decision === 'Manually via PATH' ) {
245
249
manageHLS = 'PATH' ;
246
250
} else {
247
251
window . showWarningMessage (
@@ -383,7 +387,7 @@ async function getLatestProjectHLS(
383
387
}
384
388
385
389
/**
386
- * Obtain the project ghc version from the HLS - Wrapper.
390
+ * Obtain the project ghc version from the HLS - Wrapper (which must be in PATH now) .
387
391
* Also, serves as a sanity check.
388
392
* @param wrapper Path to the Haskell-Language-Server wrapper
389
393
* @param workingDir Directory to run the process, usually the root of the workspace.
0 commit comments