aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/extension.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/extension.ts')
-rw-r--r--editors/code/src/extension.ts25
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';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3 3
4import * as commands from './commands'; 4import * as commands from './commands';
5import { interactivelyStartCargoWatch } from './commands/runnables'; 5import { CargoWatchProvider } from './commands/cargo_watch';
6import {
7 interactivelyStartCargoWatch,
8 startCargoWatch
9} from './commands/runnables';
6import { SyntaxTreeContentProvider } from './commands/syntaxTree'; 10import { SyntaxTreeContentProvider } from './commands/syntaxTree';
7import * as events from './events'; 11import * as events from './events';
8import * as notifications from './notifications'; 12import * 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();