Skip to content

Commit c508969

Browse files
committed
Prettier
1 parent 09c8e68 commit c508969

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
@@ -266,40 +266,42 @@ export async function findHaskellLanguageServer(
266266
latestStack = await getLatestToolFromGHCup(context, logger, 'stack');
267267
}
268268
if (recGHC === undefined) {
269-
recGHC = !(executableExists('ghc'))
269+
recGHC = !executableExists('ghc')
270270
? await getLatestAvailableToolFromGHCup(context, logger, 'ghc', 'recommended')
271271
: null;
272272
}
273273

274274
// download popups
275275
const promptBeforeDownloads = workspace.getConfiguration('haskell').get('promptBeforeDownloads') as boolean;
276276
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;
286280
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[];
292292
if (toInstall.length > 0) {
293293
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?`,
295295
'Yes',
296296
'No',
297297
"Yes, don't ask again"
298298
);
299299
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(', ')}.`);
301301
} 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+
);
303305
workspace.getConfiguration('haskell').update('promptBeforeDownloads', false);
304306
} else {
305307
toInstall.forEach((tool) => {
@@ -352,26 +354,25 @@ export async function findHaskellLanguageServer(
352354

353355
// more download popups
354356
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[];
363362
if (toInstall.length > 0) {
364363
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?`,
366365
{ modal: true },
367366
'Yes',
368367
'No',
369368
"Yes, don't ask again"
370369
);
371370
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(', ')}.`);
373372
} 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+
);
375376
workspace.getConfiguration('haskell').update('promptBeforeDownloads', false);
376377
} else {
377378
toInstall.forEach((tool) => {
@@ -399,7 +400,15 @@ export async function findHaskellLanguageServer(
399400
...(projectGhc ? ['--ghc', projectGhc] : []),
400401
'--install',
401402
],
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(', ')}`,
403412
true
404413
);
405414

0 commit comments

Comments
 (0)