diff options
Diffstat (limited to 'editors/code/src/extension.ts')
-rw-r--r-- | editors/code/src/extension.ts | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 1073a36a0..48dd2a614 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts | |||
@@ -2,7 +2,11 @@ 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 { interactivelyStartCargoWatch } from './commands/runnables'; | 5 | import { CargoWatchProvider } from './commands/cargo_watch'; |
6 | import { | ||
7 | interactivelyStartCargoWatch, | ||
8 | startCargoWatch | ||
9 | } from './commands/runnables'; | ||
6 | import { SyntaxTreeContentProvider } from './commands/syntaxTree'; | 10 | import { SyntaxTreeContentProvider } from './commands/syntaxTree'; |
7 | import * as events from './events'; | 11 | import * as events from './events'; |
8 | import * as notifications from './notifications'; | 12 | import * as notifications from './notifications'; |
@@ -126,7 +130,24 @@ export function activate(context: vscode.ExtensionContext) { | |||
126 | vscode.commands.registerCommand('rust-analyzer.reload', reloadCommand); | 130 | vscode.commands.registerCommand('rust-analyzer.reload', reloadCommand); |
127 | 131 | ||
128 | // Executing `cargo watch` provides us with inline diagnostics on save | 132 | // Executing `cargo watch` provides us with inline diagnostics on save |
129 | interactivelyStartCargoWatch(context); | 133 | let provider: CargoWatchProvider | undefined; |
134 | interactivelyStartCargoWatch(context).then(p => { | ||
135 | provider = p; | ||
136 | }); | ||
137 | registerCommand('rust-analyzer.startCargoWatch', () => { | ||
138 | if (provider) { | ||
139 | provider.start(); | ||
140 | } else { | ||
141 | startCargoWatch(context).then(p => { | ||
142 | provider = p; | ||
143 | }); | ||
144 | } | ||
145 | }); | ||
146 | registerCommand('rust-analyzer.stopCargoWatch', () => { | ||
147 | if (provider) { | ||
148 | provider.stop(); | ||
149 | } | ||
150 | }); | ||
130 | 151 | ||
131 | // Start the language server, finally! | 152 | // Start the language server, finally! |
132 | startServer(); | 153 | startServer(); |