-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [lean4web] abstract lean client setup to allow for websocket cl…
…ients
- Loading branch information
1 parent
403c539
commit d3c23f7
Showing
4 changed files
with
75 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node' | ||
import { serverArgs, serverLoggingEnabled, serverLoggingPath } from './config' | ||
import { ExtUri } from './utils/exturi' | ||
import { willUseLakeServer } from './utils/projectInfo' | ||
|
||
export async function setupClient( | ||
clientOptions: LanguageClientOptions, | ||
folderUri: ExtUri, | ||
elanDefaultToolchain: string, | ||
): Promise<LanguageClient> { | ||
const env = Object.assign({}, process.env) | ||
if (serverLoggingEnabled()) { | ||
env.LEAN_SERVER_LOG_DIR = serverLoggingPath() | ||
} | ||
|
||
let serverExecutable | ||
let options | ||
if (await willUseLakeServer(folderUri)) { | ||
;[serverExecutable, options] = ['lake', ['serve', '--']] | ||
} else { | ||
;[serverExecutable, options] = ['lean', ['--server']] | ||
} | ||
|
||
const cwd = folderUri.scheme === 'file' ? folderUri.fsPath : undefined | ||
if (cwd) { | ||
// Add folder name to command-line so that it shows up in `ps aux`. | ||
options.push(cwd) | ||
} else { | ||
// Fixes issue #227, for adhoc files it would pick up the cwd from the open folder | ||
// which is not what we want. For adhoc files we want the (default) toolchain instead. | ||
options.unshift('+' + elanDefaultToolchain) | ||
options.push('untitled') | ||
} | ||
|
||
const serverOptions: ServerOptions = { | ||
command: serverExecutable, | ||
args: options.concat(serverArgs()), | ||
options: { | ||
cwd, | ||
env, | ||
}, | ||
} | ||
|
||
return new LanguageClient('lean4', 'Lean 4', serverOptions, clientOptions) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters