diff options
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r-- | editors/code/src/commands/index.ts | 1 | ||||
-rw-r--r-- | editors/code/src/commands/server_version.ts | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index bebd99ca9..839245f48 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts | |||
@@ -13,6 +13,7 @@ export * from './syntax_tree'; | |||
13 | export * from './expand_macro'; | 13 | export * from './expand_macro'; |
14 | export * from './runnables'; | 14 | export * from './runnables'; |
15 | export * from './ssr'; | 15 | export * from './ssr'; |
16 | export * from './server_version'; | ||
16 | 17 | ||
17 | export function collectGarbage(ctx: Ctx): Cmd { | 18 | export function collectGarbage(ctx: Ctx): Cmd { |
18 | return async () => { | 19 | return async () => { |
diff --git a/editors/code/src/commands/server_version.ts b/editors/code/src/commands/server_version.ts new file mode 100644 index 000000000..421301b42 --- /dev/null +++ b/editors/code/src/commands/server_version.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | import { ensureServerBinary } from '../installation/server'; | ||
3 | import { Ctx, Cmd } from '../ctx'; | ||
4 | import { spawnSync } from 'child_process'; | ||
5 | |||
6 | export function serverVersion(ctx: Ctx): Cmd { | ||
7 | return async () => { | ||
8 | const binaryPath = await ensureServerBinary(ctx.config.serverSource); | ||
9 | |||
10 | if (binaryPath == null) { | ||
11 | throw new Error( | ||
12 | "Rust Analyzer Language Server is not available. " + | ||
13 | "Please, ensure its [proper installation](https://rust-analyzer.github.io/manual.html#installation)." | ||
14 | ); | ||
15 | } | ||
16 | |||
17 | const version = spawnSync(binaryPath, ["--version"], { encoding: "utf8" }).stdout; | ||
18 | vscode.window.showInformationMessage('rust-analyzer version : ' + version); | ||
19 | }; | ||
20 | } | ||
21 | |||