Skip to content

Commit 50d57f2

Browse files
authored
feat: improve server startup progress bar message (#619)
This PR adjusts the progress bar message to reflect that it is cloning missing packages (suggesting that it may hence take a while). It also adjusts the output of `lake serve` in the output panel to mention the command that was called.
1 parent 6421d7c commit 50d57f2

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

vscode-lean4/src/leanclient.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import {
1818
DidChangeTextDocumentParams,
1919
DidCloseTextDocumentParams,
2020
DocumentFilter,
21+
Executable,
2122
InitializeResult,
2223
LanguageClient,
2324
LanguageClientOptions,
2425
RevealOutputChannelOn,
25-
ServerOptions,
2626
State,
2727
StaticFeature,
2828
} from 'vscode-languageclient/node'
@@ -44,6 +44,7 @@ import {
4444
import { logger } from './utils/logger'
4545
// @ts-ignore
4646
import { SemVer } from 'semver'
47+
import { formatCommandExecutionOutput } from './utils/batch'
4748
import {
4849
c2pConverter,
4950
LeanPublishDiagnosticsParams,
@@ -214,7 +215,7 @@ export class LeanClient implements Disposable {
214215

215216
const progressOptions: ProgressOptions = {
216217
location: ProgressLocation.Notification,
217-
title: '[Server Startup] Starting Lean language client',
218+
title: '[Server Startup] Starting Lean language server and cloning missing packages [(Click for details)](command:lean4.troubleshooting.showOutput)',
218219
cancellable: false,
219220
}
220221
await window.withProgress(
@@ -542,7 +543,7 @@ export class LeanClient implements Disposable {
542543
return this.running ? this.client?.initializeResult : undefined
543544
}
544545

545-
private async determineServerOptions(toolchainOverride: string | undefined): Promise<ServerOptions> {
546+
private async determineServerOptions(toolchainOverride: string | undefined): Promise<Executable> {
546547
const env = Object.assign({}, process.env)
547548
if (serverLoggingEnabled()) {
548549
env.LEAN_SERVER_LOG_DIR = serverLoggingPath()
@@ -711,9 +712,12 @@ export class LeanClient implements Disposable {
711712
}
712713

713714
private async setupClient(toolchainOverride: string | undefined): Promise<LanguageClient> {
714-
const serverOptions: ServerOptions = await this.determineServerOptions(toolchainOverride)
715+
const serverOptions: Executable = await this.determineServerOptions(toolchainOverride)
715716
const clientOptions: LanguageClientOptions = this.obtainClientOptions()
716717

718+
this.outputChannel.appendLine(
719+
formatCommandExecutionOutput(serverOptions.options?.cwd, serverOptions.command, serverOptions.args ?? []),
720+
)
717721
const client = new LanguageClient('lean4', 'Lean 4', serverOptions, clientOptions)
718722
const leanCapabilityFeature: StaticFeature = {
719723
initialize(_1, _2) {},

vscode-lean4/src/utils/batch.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ function createCannotLaunchExecutionResult(message: string): ExecutionResult {
3232
}
3333
}
3434

35+
export function formatCommandExecutionOutput(
36+
workingDirectory: string | undefined,
37+
executablePath: string,
38+
args: string[],
39+
) {
40+
const formattedCwd = workingDirectory ? `${workingDirectory}` : ''
41+
const formattedArgs = args.map(arg => (arg.includes(' ') ? `"${arg}"` : arg)).join(' ')
42+
return `${formattedCwd}> ${executablePath} ${formattedArgs}`
43+
}
44+
3545
export function batchExecuteWithProc(
3646
executablePath: string,
3747
args: string[],
@@ -54,9 +64,7 @@ export function batchExecuteWithProc(
5464
options = { ...options, env }
5565
}
5666
if (channel?.combined) {
57-
const formattedCwd = workingDirectory ? `${workingDirectory}` : ''
58-
const formattedArgs = args.map(arg => (arg.includes(' ') ? `"${arg}"` : arg)).join(' ')
59-
channel.combined.appendLine(`${formattedCwd}> ${executablePath} ${formattedArgs}`)
67+
channel.combined.appendLine(formatCommandExecutionOutput(workingDirectory, executablePath, args))
6068
}
6169

6270
let proc: ChildProcessWithoutNullStreams

0 commit comments

Comments
 (0)