1 import * as vscode from 'vscode';
2 import * as lc from 'vscode-languageclient';
3 import { Server } from './server';
6 private extCtx: vscode.ExtensionContext;
8 constructor(extCtx: vscode.ExtensionContext) {
12 get client(): lc.LanguageClient {
16 get activeRustEditor(): vscode.TextEditor | undefined {
17 const editor = vscode.window.activeTextEditor;
18 return editor && editor.document.languageId === 'rust'
23 registerCommand(name: string, factory: (ctx: Ctx) => Cmd) {
24 const fullName = `rust-analyzer.${name}`;
25 const cmd = factory(this);
26 const d = vscode.commands.registerCommand(fullName, cmd);
30 pushCleanup(d: { dispose(): any }) {
31 this.extCtx.subscriptions.push(d);
35 export type Cmd = (...args: any[]) => any;