1
1
import * as vscode from 'vscode' ;
2
+ import * as lc from 'vscode-languageclient/node' ;
2
3
import * as os from "os" ;
3
4
4
5
import * as commands from './commands' ;
@@ -14,16 +15,20 @@ let ctx: Ctx | undefined;
14
15
15
16
const RUST_PROJECT_CONTEXT_NAME = "inRustProject" ;
16
17
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 > {
18
23
// VS Code doesn't show a notification when an extension fails to activate
19
24
// so we do it ourselves.
20
- await tryActivate ( context ) . catch ( err => {
25
+ return await tryActivate ( context ) . catch ( err => {
21
26
void vscode . window . showErrorMessage ( `Cannot activate rust-analyzer: ${ err . message } ` ) ;
22
27
throw err ;
23
28
} ) ;
24
29
}
25
30
26
- async function tryActivate ( context : vscode . ExtensionContext ) {
31
+ async function tryActivate ( context : vscode . ExtensionContext ) : Promise < RustAnalyzerExtensionApi > {
27
32
const config = new Config ( context ) ;
28
33
const state = new PersistentState ( context . globalState ) ;
29
34
const serverPath = await bootstrap ( context , config , state ) . catch ( err => {
@@ -62,6 +67,10 @@ async function tryActivate(context: vscode.ExtensionContext) {
62
67
null ,
63
68
ctx . subscriptions ,
64
69
) ;
70
+
71
+ return {
72
+ client : ctx . client
73
+ } ;
65
74
}
66
75
67
76
async function initCommonContext ( context : vscode . ExtensionContext , ctx : Ctx ) {
0 commit comments