aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/commands/watch_status.ts43
-rw-r--r--editors/code/src/extension.ts8
2 files changed, 51 insertions, 0 deletions
diff --git a/editors/code/src/commands/watch_status.ts b/editors/code/src/commands/watch_status.ts
index 8d64394c7..2404c3f16 100644
--- a/editors/code/src/commands/watch_status.ts
+++ b/editors/code/src/commands/watch_status.ts
@@ -57,7 +57,50 @@ export class StatusDisplay implements vscode.Disposable {
57 this.statusBarItem.dispose(); 57 this.statusBarItem.dispose();
58 } 58 }
59 59
60 public handleProgressNotification(params: ProgressParams) {
61 const { token, value } = params;
62 if (token !== "rustAnalyzer/cargoWatcher") {
63 return;
64 }
65
66 console.log("Got progress notification", token, value)
67 switch (value.kind) {
68 case "begin":
69 this.show();
70 break;
71
72 case "report":
73 if (value.message) {
74 this.packageName = value.message;
75 }
76 break;
77
78 case "end":
79 this.hide();
80 break;
81 }
82 }
83
60 private frame() { 84 private frame() {
61 return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)]; 85 return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)];
62 } 86 }
63} 87}
88
89// FIXME: Replace this once vscode-languageclient is updated to LSP 3.15
90interface ProgressParams {
91 token: string
92 value: WorkDoneProgress
93}
94
95enum WorkDoneProgressKind {
96 Begin = "begin",
97 Report = "report",
98 End = "end"
99}
100
101interface WorkDoneProgress {
102 kind: WorkDoneProgressKind,
103 message?: string
104 cancelable?: boolean
105 percentage?: string
106} \ No newline at end of file
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts
index 72a4d4bf2..1507cb26e 100644
--- a/editors/code/src/extension.ts
+++ b/editors/code/src/extension.ts
@@ -8,6 +8,7 @@ import { SyntaxTreeContentProvider } from './commands/syntaxTree';
8import * as events from './events'; 8import * as events from './events';
9import * as notifications from './notifications'; 9import * as notifications from './notifications';
10import { Server } from './server'; 10import { Server } from './server';
11import { StatusDisplay } from './commands/watch_status';
11 12
12export async function activate(context: vscode.ExtensionContext) { 13export async function activate(context: vscode.ExtensionContext) {
13 function disposeOnDeactivation(disposable: vscode.Disposable) { 14 function disposeOnDeactivation(disposable: vscode.Disposable) {
@@ -83,6 +84,9 @@ export async function activate(context: vscode.ExtensionContext) {
83 overrideCommand('type', commands.onEnter.handle); 84 overrideCommand('type', commands.onEnter.handle);
84 } 85 }
85 86
87 const watchStatus = new StatusDisplay(Server.config.cargoCheckOptions.command || 'check');
88 disposeOnDeactivation(watchStatus);
89
86 // Notifications are events triggered by the language server 90 // Notifications are events triggered by the language server
87 const allNotifications: Iterable<[ 91 const allNotifications: Iterable<[
88 string, 92 string,
@@ -92,6 +96,10 @@ export async function activate(context: vscode.ExtensionContext) {
92 'rust-analyzer/publishDecorations', 96 'rust-analyzer/publishDecorations',
93 notifications.publishDecorations.handle, 97 notifications.publishDecorations.handle,
94 ], 98 ],
99 [
100 '$/progress',
101 (params) => watchStatus.handleProgressNotification(params),
102 ]
95 ]; 103 ];
96 const syntaxTreeContentProvider = new SyntaxTreeContentProvider(); 104 const syntaxTreeContentProvider = new SyntaxTreeContentProvider();
97 const expandMacroContentProvider = new ExpandMacroContentProvider(); 105 const expandMacroContentProvider = new ExpandMacroContentProvider();