diff options
Diffstat (limited to 'editors/code/src/extension.ts')
-rw-r--r-- | editors/code/src/extension.ts | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 815f3692c..1da10ebd0 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts | |||
@@ -2,14 +2,10 @@ import * as vscode from 'vscode'; | |||
2 | import * as lc from 'vscode-languageclient'; | 2 | import * as lc from 'vscode-languageclient'; |
3 | 3 | ||
4 | import * as commands from './commands'; | 4 | import * as commands from './commands'; |
5 | import { CargoWatchProvider } from './commands/cargo_watch'; | ||
6 | import { ExpandMacroContentProvider } from './commands/expand_macro'; | 5 | import { ExpandMacroContentProvider } from './commands/expand_macro'; |
7 | import { HintsUpdater } from './commands/inlay_hints'; | 6 | import { HintsUpdater } from './commands/inlay_hints'; |
8 | import { | ||
9 | interactivelyStartCargoWatch, | ||
10 | startCargoWatch, | ||
11 | } from './commands/runnables'; | ||
12 | import { SyntaxTreeContentProvider } from './commands/syntaxTree'; | 7 | import { SyntaxTreeContentProvider } from './commands/syntaxTree'; |
8 | import { StatusDisplay } from './commands/watch_status'; | ||
13 | import * as events from './events'; | 9 | import * as events from './events'; |
14 | import * as notifications from './notifications'; | 10 | import * as notifications from './notifications'; |
15 | import { Server } from './server'; | 11 | import { Server } from './server'; |
@@ -88,6 +84,11 @@ export async function activate(context: vscode.ExtensionContext) { | |||
88 | overrideCommand('type', commands.onEnter.handle); | 84 | overrideCommand('type', commands.onEnter.handle); |
89 | } | 85 | } |
90 | 86 | ||
87 | const watchStatus = new StatusDisplay( | ||
88 | Server.config.cargoWatchOptions.command, | ||
89 | ); | ||
90 | disposeOnDeactivation(watchStatus); | ||
91 | |||
91 | // Notifications are events triggered by the language server | 92 | // Notifications are events triggered by the language server |
92 | const allNotifications: Iterable<[ | 93 | const allNotifications: Iterable<[ |
93 | string, | 94 | string, |
@@ -97,6 +98,10 @@ export async function activate(context: vscode.ExtensionContext) { | |||
97 | 'rust-analyzer/publishDecorations', | 98 | 'rust-analyzer/publishDecorations', |
98 | notifications.publishDecorations.handle, | 99 | notifications.publishDecorations.handle, |
99 | ], | 100 | ], |
101 | [ | ||
102 | '$/progress', | ||
103 | params => watchStatus.handleProgressNotification(params), | ||
104 | ], | ||
100 | ]; | 105 | ]; |
101 | const syntaxTreeContentProvider = new SyntaxTreeContentProvider(); | 106 | const syntaxTreeContentProvider = new SyntaxTreeContentProvider(); |
102 | const expandMacroContentProvider = new ExpandMacroContentProvider(); | 107 | const expandMacroContentProvider = new ExpandMacroContentProvider(); |
@@ -139,26 +144,6 @@ export async function activate(context: vscode.ExtensionContext) { | |||
139 | 144 | ||
140 | vscode.commands.registerCommand('rust-analyzer.reload', reloadCommand); | 145 | vscode.commands.registerCommand('rust-analyzer.reload', reloadCommand); |
141 | 146 | ||
142 | // Executing `cargo watch` provides us with inline diagnostics on save | ||
143 | let provider: CargoWatchProvider | undefined; | ||
144 | interactivelyStartCargoWatch(context).then(p => { | ||
145 | provider = p; | ||
146 | }); | ||
147 | registerCommand('rust-analyzer.startCargoWatch', () => { | ||
148 | if (provider) { | ||
149 | provider.start(); | ||
150 | } else { | ||
151 | startCargoWatch(context).then(p => { | ||
152 | provider = p; | ||
153 | }); | ||
154 | } | ||
155 | }); | ||
156 | registerCommand('rust-analyzer.stopCargoWatch', () => { | ||
157 | if (provider) { | ||
158 | provider.stop(); | ||
159 | } | ||
160 | }); | ||
161 | |||
162 | // Start the language server, finally! | 147 | // Start the language server, finally! |
163 | try { | 148 | try { |
164 | await startServer(); | 149 | await startServer(); |