diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-20 15:02:36 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-20 15:02:36 +0100 |
commit | 526a6aba104a32eb9f0f5a65232783d5570c35d5 (patch) | |
tree | f8f6687924cb15a2d759dae02205b7f28a5f83fd /editors/code/src/extension.ts | |
parent | 0d39b1c3fa03a8032ea96be922fd62710f811aba (diff) | |
parent | 4cd0a96c96870d4e9a73b92f401a8fad26f3c02a (diff) |
Merge #1174
1174: improve cargo watch r=matklad a=vemoo
- Add start and stop commands
- Cleanup trypescript code to avoid definite assignment assertions (`!` after possibly undefined value)
- Recover `rustc-watch` problem matcher because it's still useful, can be used with any command, for example `cargo test`
Co-authored-by: Bernardo <[email protected]>
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(); |