Skip to content

Commit 4398241

Browse files
committed
Prettier
1 parent 0775b99 commit 4398241

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed

src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ export class NoMatchingHls extends Error {
5454
super(`HLS does not support GHC ${ghcProjVersion} yet.`);
5555
}
5656
public docLink(): Uri {
57-
return Uri.parse('https://haskell-language-server.readthedocs.io/en/latest/supported-versions.html');
57+
return Uri.parse('https://haskell-language-server.readthedocs.io/en/latest/supported-versions.html');
5858
}
5959
}

src/hlsBinaries.ts

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -265,40 +265,42 @@ export async function findHaskellLanguageServer(
265265
latestStack = await getLatestToolFromGHCup(context, logger, 'stack');
266266
}
267267
if (recGHC === undefined) {
268-
recGHC = !(executableExists('ghc'))
268+
recGHC = !executableExists('ghc')
269269
? await getLatestAvailableToolFromGHCup(context, logger, 'ghc', 'recommended')
270270
: null;
271271
}
272272

273273
// download popups
274274
const promptBeforeDownloads = workspace.getConfiguration('haskell').get('promptBeforeDownloads') as boolean;
275275
if (promptBeforeDownloads) {
276-
const hlsInstalled = latestHLS
277-
? await toolInstalled(context, logger, 'hls', latestHLS)
278-
: undefined;
279-
const cabalInstalled = latestCabal
280-
? await toolInstalled(context, logger, 'cabal', latestCabal)
281-
: undefined;
282-
const stackInstalled = latestStack
283-
? await toolInstalled(context, logger, 'stack', latestStack)
284-
: undefined;
276+
const hlsInstalled = latestHLS ? await toolInstalled(context, logger, 'hls', latestHLS) : undefined;
277+
const cabalInstalled = latestCabal ? await toolInstalled(context, logger, 'cabal', latestCabal) : undefined;
278+
const stackInstalled = latestStack ? await toolInstalled(context, logger, 'stack', latestStack) : undefined;
285279
const ghcInstalled = executableExists('ghc')
286-
? new InstalledTool('ghc', await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false))
287-
// if recGHC is null, that means user disabled automatic handling,
288-
: (recGHC !== null ? await toolInstalled(context, logger, 'ghc', recGHC) : undefined);
289-
const toInstall: InstalledTool[] = [hlsInstalled, cabalInstalled, stackInstalled, ghcInstalled]
290-
.filter((tool) => tool && !tool.installed) as InstalledTool[];
280+
? new InstalledTool(
281+
'ghc',
282+
await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false)
283+
)
284+
: // if recGHC is null, that means user disabled automatic handling,
285+
recGHC !== null
286+
? await toolInstalled(context, logger, 'ghc', recGHC)
287+
: undefined;
288+
const toInstall: InstalledTool[] = [hlsInstalled, cabalInstalled, stackInstalled, ghcInstalled].filter(
289+
(tool) => tool && !tool.installed
290+
) as InstalledTool[];
291291
if (toInstall.length > 0) {
292292
const decision = await window.showInformationMessage(
293-
`Need to download ${toInstall.map(t => t.nameWithVersion).join(', ')}, continue?`,
293+
`Need to download ${toInstall.map((t) => t.nameWithVersion).join(', ')}, continue?`,
294294
'Yes',
295295
'No',
296296
"Yes, don't ask again"
297297
);
298298
if (decision === 'Yes') {
299-
logger.info(`User accepted download for ${toInstall.map(t => t.nameWithVersion).join(', ')}.`);
299+
logger.info(`User accepted download for ${toInstall.map((t) => t.nameWithVersion).join(', ')}.`);
300300
} else if (decision === "Yes, don't ask again") {
301-
logger.info(`User accepted download for ${toInstall.map(t => t.nameWithVersion).join(', ')} and won't be asked again.`);
301+
logger.info(
302+
`User accepted download for ${toInstall.map((t) => t.nameWithVersion).join(', ')} and won't be asked again.`
303+
);
302304
workspace.getConfiguration('haskell').update('promptBeforeDownloads', false);
303305
} else {
304306
toInstall.forEach((tool) => {
@@ -351,26 +353,25 @@ export async function findHaskellLanguageServer(
351353

352354
// more download popups
353355
if (promptBeforeDownloads) {
354-
const hlsInstalled = projectHls
355-
? await toolInstalled(context, logger, 'hls', projectHls)
356-
: undefined;
357-
const ghcInstalled = projectGhc
358-
? await toolInstalled(context, logger, 'ghc', projectGhc)
359-
: undefined;
360-
const toInstall: InstalledTool[] = [hlsInstalled, ghcInstalled]
361-
.filter((tool) => tool && !tool.installed) as InstalledTool[];
356+
const hlsInstalled = projectHls ? await toolInstalled(context, logger, 'hls', projectHls) : undefined;
357+
const ghcInstalled = projectGhc ? await toolInstalled(context, logger, 'ghc', projectGhc) : undefined;
358+
const toInstall: InstalledTool[] = [hlsInstalled, ghcInstalled].filter(
359+
(tool) => tool && !tool.installed
360+
) as InstalledTool[];
362361
if (toInstall.length > 0) {
363362
const decision = await window.showInformationMessage(
364-
`Need to download ${toInstall.map(t => t.nameWithVersion).join(', ')}, continue?`,
363+
`Need to download ${toInstall.map((t) => t.nameWithVersion).join(', ')}, continue?`,
365364
{ modal: true },
366365
'Yes',
367366
'No',
368367
"Yes, don't ask again"
369368
);
370369
if (decision === 'Yes') {
371-
logger.info(`User accepted download for ${toInstall.map(t => t.nameWithVersion).join(', ')}.`);
370+
logger.info(`User accepted download for ${toInstall.map((t) => t.nameWithVersion).join(', ')}.`);
372371
} else if (decision === "Yes, don't ask again") {
373-
logger.info(`User accepted download for ${toInstall.map(t => t.nameWithVersion).join(', ')} and won't be asked again.`);
372+
logger.info(
373+
`User accepted download for ${toInstall.map((t) => t.nameWithVersion).join(', ')} and won't be asked again.`
374+
);
374375
workspace.getConfiguration('haskell').update('promptBeforeDownloads', false);
375376
} else {
376377
toInstall.forEach((tool) => {
@@ -398,7 +399,15 @@ export async function findHaskellLanguageServer(
398399
...(projectGhc ? ['--ghc', projectGhc] : []),
399400
'--install',
400401
],
401-
`Installing project specific toolchain: ${[['hls', projectHls], ['GHC', projectGhc], ['cabal', latestCabal], ['stack', latestStack]].filter(t => t[1]).map(t => `${t[0]}-${t[1]}`).join(', ')}`,
402+
`Installing project specific toolchain: ${[
403+
['hls', projectHls],
404+
['GHC', projectGhc],
405+
['cabal', latestCabal],
406+
['stack', latestStack],
407+
]
408+
.filter((t) => t[1])
409+
.map((t) => `${t[0]}-${t[1]}`)
410+
.join(', ')}`,
402411
true
403412
);
404413

0 commit comments

Comments
 (0)