aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/runnables.ts
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-03-31 13:00:50 +0100
committerEdwin Cheng <[email protected]>2019-04-02 08:03:30 +0100
commitb3683df0cd67ca97c83f5a7ea58a780dbe4e1b8e (patch)
tree19b36b1a771914586cf79dd4e141ebf7a6219e18 /editors/code/src/commands/runnables.ts
parentc2912892effbcf24d94da235b9ac0d2a7fccea5d (diff)
Improve cargo-watch usage
Diffstat (limited to 'editors/code/src/commands/runnables.ts')
-rw-r--r--editors/code/src/commands/runnables.ts29
1 files changed, 7 insertions, 22 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index 4187ef4d1..722db158a 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -1,9 +1,11 @@
1import * as child_process from 'child_process'; 1import * as child_process from 'child_process';
2
2import * as util from 'util'; 3import * as util from 'util';
3import * as vscode from 'vscode'; 4import * as vscode from 'vscode';
4import * as lc from 'vscode-languageclient'; 5import * as lc from 'vscode-languageclient';
5 6
6import { Server } from '../server'; 7import { Server } from '../server';
8import { CargoWatchProvider } from './cargo_watch';
7 9
8interface RunnablesParams { 10interface RunnablesParams {
9 textDocument: lc.TextDocumentIdentifier; 11 textDocument: lc.TextDocumentIdentifier;
@@ -127,32 +129,13 @@ export async function handleSingle(runnable: Runnable) {
127 return vscode.tasks.executeTask(task); 129 return vscode.tasks.executeTask(task);
128} 130}
129 131
130export const autoCargoWatchTask: vscode.Task = {
131 name: 'cargo watch',
132 source: 'rust-analyzer',
133 definition: {
134 type: 'watch'
135 },
136 execution: new vscode.ShellExecution('cargo', ['watch'], { cwd: '.' }),
137
138 isBackground: true,
139 problemMatchers: ['$rustc-watch'],
140 presentationOptions: {
141 clear: true
142 },
143 // Not yet exposed in the vscode.d.ts
144 // https://github.com/Microsoft/vscode/blob/ea7c31d770e04b51d586b0d3944f3a7feb03afb9/src/vs/workbench/contrib/tasks/common/tasks.ts#L444-L456
145 runOptions: ({
146 runOn: 2 // RunOnOptions.folderOpen
147 } as unknown) as vscode.RunOptions
148};
149
150/** 132/**
151 * Interactively asks the user whether we should run `cargo check` in order to 133 * Interactively asks the user whether we should run `cargo check` in order to
152 * provide inline diagnostics; the user is met with a series of dialog boxes 134 * provide inline diagnostics; the user is met with a series of dialog boxes
153 * that, when accepted, allow us to `cargo install cargo-watch` and then run it. 135 * that, when accepted, allow us to `cargo install cargo-watch` and then run it.
154 */ 136 */
155export async function interactivelyStartCargoWatch() { 137export async function interactivelyStartCargoWatch(context: vscode.ExtensionContext) {
138
156 if (Server.config.enableCargoWatchOnStartup === 'disabled') { 139 if (Server.config.enableCargoWatchOnStartup === 'disabled') {
157 return; 140 return;
158 } 141 }
@@ -212,5 +195,7 @@ export async function interactivelyStartCargoWatch() {
212 } 195 }
213 } 196 }
214 197
215 vscode.tasks.executeTask(autoCargoWatchTask); 198
199 let validater = new CargoWatchProvider();
200 validater.activate(context.subscriptions);
216} 201}