Skip to content

Commit 1dc4213

Browse files
committed
Fixes
1 parent 9c82faa commit 1dc4213

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/hlsBinaries.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class MissingToolError extends Error {
3939
public readonly tool: string;
4040
constructor(tool: string) {
4141
let prettyTool: string;
42-
switch (tool) {
42+
switch (tool.toLowerCase()) {
4343
case 'stack':
4444
prettyTool = 'Stack';
4545
break;
@@ -52,6 +52,12 @@ export class MissingToolError extends Error {
5252
case 'ghcup':
5353
prettyTool = 'GHCup';
5454
break;
55+
case 'haskell-language-server':
56+
prettyTool = 'HLS';
57+
break;
58+
case 'hls':
59+
prettyTool = 'HLS';
60+
break;
5561
default:
5662
prettyTool = tool;
5763
break;
@@ -66,6 +72,7 @@ export class MissingToolError extends Error {
6672
return Uri.parse('https://docs.haskellstack.org/en/stable/install_and_upgrade/');
6773
case 'GHCup':
6874
case 'Cabal':
75+
case 'HLS':
6976
case 'GHC':
7077
return Uri.parse('https://www.haskell.org/ghcup/');
7178
default:
@@ -109,8 +116,7 @@ async function callAsync(
109116
let newEnv: IEnvVars = await resolveServerEnvironmentPATH(
110117
workspace.getConfiguration('haskell').get('serverEnvironment') || {}
111118
);
112-
newEnv = { ...(process.env as IEnvVars), ...newEnv };
113-
newEnv = { ...newEnv, ...(envAdd || {}) };
119+
newEnv = { ...(process.env as IEnvVars), ...newEnv, ...(envAdd || {}) };
114120
return window.withProgress(
115121
{
116122
location: ProgressLocation.Notification,
@@ -120,7 +126,7 @@ async function callAsync(
120126
async (_, token) => {
121127
return new Promise<string>((resolve, reject) => {
122128
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()}'`);
124130
token.onCancellationRequested(() => {
125131
logger.warn(`User canceled the execution of '${command}'`);
126132
});
@@ -197,9 +203,7 @@ async function findHLSinPATH(context: ExtensionContext, logger: Logger, folder?:
197203
return exe;
198204
}
199205
}
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');
203207
}
204208

205209
/**
@@ -238,10 +242,10 @@ export async function findHaskellLanguageServer(
238242
const promptMessage = 'How do you want the extension to manage/discover HLS and the relevant toolchain?';
239243

240244
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') {
243247
manageHLS = 'GHCup';
244-
} else if (decision === 'manually via PATH') {
248+
} else if (decision === 'Manually via PATH') {
245249
manageHLS = 'PATH';
246250
} else {
247251
window.showWarningMessage(
@@ -383,7 +387,7 @@ async function getLatestProjectHLS(
383387
}
384388

385389
/**
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).
387391
* Also, serves as a sanity check.
388392
* @param wrapper Path to the Haskell-Language-Server wrapper
389393
* @param workingDir Directory to run the process, usually the root of the workspace.

0 commit comments

Comments
 (0)