diff options
Diffstat (limited to 'editors/code/src/commands/runnables.ts')
-rw-r--r-- | editors/code/src/commands/runnables.ts | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 4187ef4d1..3589edcee 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts | |||
@@ -1,9 +1,11 @@ | |||
1 | import * as child_process from 'child_process'; | 1 | import * as child_process from 'child_process'; |
2 | |||
2 | import * as util from 'util'; | 3 | import * as util from 'util'; |
3 | import * as vscode from 'vscode'; | 4 | import * as vscode from 'vscode'; |
4 | import * as lc from 'vscode-languageclient'; | 5 | import * as lc from 'vscode-languageclient'; |
5 | 6 | ||
6 | import { Server } from '../server'; | 7 | import { Server } from '../server'; |
8 | import { CargoWatchProvider } from './cargo_watch'; | ||
7 | 9 | ||
8 | interface RunnablesParams { | 10 | interface RunnablesParams { |
9 | textDocument: lc.TextDocumentIdentifier; | 11 | textDocument: lc.TextDocumentIdentifier; |
@@ -127,37 +129,19 @@ export async function handleSingle(runnable: Runnable) { | |||
127 | return vscode.tasks.executeTask(task); | 129 | return vscode.tasks.executeTask(task); |
128 | } | 130 | } |
129 | 131 | ||
130 | export 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 | */ |
155 | export async function interactivelyStartCargoWatch() { | 137 | export async function interactivelyStartCargoWatch( |
156 | if (Server.config.enableCargoWatchOnStartup === 'disabled') { | 138 | context: vscode.ExtensionContext |
139 | ) { | ||
140 | if (Server.config.cargoWatchOptions.enableOnStartup === 'disabled') { | ||
157 | return; | 141 | return; |
158 | } | 142 | } |
159 | 143 | ||
160 | if (Server.config.enableCargoWatchOnStartup === 'ask') { | 144 | if (Server.config.cargoWatchOptions.enableOnStartup === 'ask') { |
161 | const watch = await vscode.window.showInformationMessage( | 145 | const watch = await vscode.window.showInformationMessage( |
162 | 'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics)', | 146 | 'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics)', |
163 | 'yes', | 147 | 'yes', |
@@ -212,5 +196,6 @@ export async function interactivelyStartCargoWatch() { | |||
212 | } | 196 | } |
213 | } | 197 | } |
214 | 198 | ||
215 | vscode.tasks.executeTask(autoCargoWatchTask); | 199 | const validater = new CargoWatchProvider(); |
200 | validater.activate(context.subscriptions); | ||
216 | } | 201 | } |