Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d607c1b

Browse files
committed
Export lc.LanguageClient from VSCode extension
1 parent 1db66b9 commit d607c1b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

editors/code/src/main.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from 'vscode';
2+
import * as lc from 'vscode-languageclient/node';
23
import * as os from "os";
34

45
import * as commands from './commands';
@@ -14,16 +15,20 @@ let ctx: Ctx | undefined;
1415

1516
const RUST_PROJECT_CONTEXT_NAME = "inRustProject";
1617

17-
export async function activate(context: vscode.ExtensionContext) {
18+
export interface RustAnalyzerExtensionApi {
19+
client: lc.LanguageClient;
20+
}
21+
22+
export async function activate(context: vscode.ExtensionContext): Promise<RustAnalyzerExtensionApi> {
1823
// VS Code doesn't show a notification when an extension fails to activate
1924
// so we do it ourselves.
20-
await tryActivate(context).catch(err => {
25+
return await tryActivate(context).catch(err => {
2126
void vscode.window.showErrorMessage(`Cannot activate rust-analyzer: ${err.message}`);
2227
throw err;
2328
});
2429
}
2530

26-
async function tryActivate(context: vscode.ExtensionContext) {
31+
async function tryActivate(context: vscode.ExtensionContext): Promise<RustAnalyzerExtensionApi> {
2732
const config = new Config(context);
2833
const state = new PersistentState(context.globalState);
2934
const serverPath = await bootstrap(context, config, state).catch(err => {
@@ -62,6 +67,10 @@ async function tryActivate(context: vscode.ExtensionContext) {
6267
null,
6368
ctx.subscriptions,
6469
);
70+
71+
return {
72+
client: ctx.client
73+
};
6574
}
6675

6776
async function initCommonContext(context: vscode.ExtensionContext, ctx: Ctx) {

0 commit comments

Comments
 (0)