File tree 3 files changed +31
-16
lines changed
3 files changed +31
-16
lines changed Original file line number Diff line number Diff line change 169
169
"description" : " Path to ra_lsp_server executable"
170
170
},
171
171
"rust-analyzer.enableCargoWatchOnStartup" : {
172
- "type" : " boolean" ,
173
- "default" : " true" ,
174
- "description" : " When enabled, ask the user whether to run `cargo watch` on startup"
172
+ "type" : " string" ,
173
+ "default" : " ask" ,
174
+ "enum" : [
175
+ " ask" ,
176
+ " enabled" ,
177
+ " disabled"
178
+ ],
179
+ "enumDescriptions" : [
180
+ " Asks each time whether to run `cargo watch`" ,
181
+ " `cargo watch` is always started" ,
182
+ " Don't start `cargo watch`"
183
+ ],
184
+ "description" : " Whether to run `cargo watch` on startup"
175
185
},
176
186
"rust-analyzer.trace.server" : {
177
187
"type" : " string" ,
Original file line number Diff line number Diff line change @@ -153,22 +153,25 @@ export const autoCargoWatchTask: vscode.Task = {
153
153
* that, when accepted, allow us to `cargo install cargo-watch` and then run it.
154
154
*/
155
155
export async function interactivelyStartCargoWatch ( ) {
156
- if ( ! Server . config . enableCargoWatchOnStartup ) {
156
+ if ( Server . config . enableCargoWatchOnStartup === 'disabled' ) {
157
157
return ;
158
158
}
159
159
160
- const execPromise = util . promisify ( child_process . exec ) ;
161
-
162
- const watch = await vscode . window . showInformationMessage (
163
- 'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics) ',
164
- 'yes' ,
165
- 'no'
166
- ) ;
167
- if ( watch === 'no' ) {
168
- return ;
160
+ if ( Server . config . enableCargoWatchOnStartup === 'ask' ) {
161
+ const watch = await vscode . window . showInformationMessage (
162
+ 'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics)' ,
163
+ 'yes ',
164
+ 'no'
165
+ ) ;
166
+ if ( watch === 'no' ) {
167
+ return ;
168
+ }
169
169
}
170
170
171
+ const execPromise = util . promisify ( child_process . exec ) ;
172
+
171
173
const { stderr } = await execPromise ( 'cargo watch --version' ) . catch ( e => e ) ;
174
+
172
175
if ( stderr . includes ( 'no such subcommand: `watch`' ) ) {
173
176
const msg =
174
177
'The `cargo-watch` subcommand is not installed. Install? (takes ~1-2 minutes)' ;
Original file line number Diff line number Diff line change @@ -4,12 +4,14 @@ import { Server } from './server';
4
4
5
5
const RA_LSP_DEBUG = process . env . __RA_LSP_SERVER_DEBUG ;
6
6
7
+ export type CargoWatchOptions = 'ask' | 'enabled' | 'disabled' ;
8
+
7
9
export class Config {
8
10
public highlightingOn = true ;
9
11
public enableEnhancedTyping = true ;
10
12
public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server' ;
11
13
public showWorkspaceLoadedNotification = true ;
12
- public enableCargoWatchOnStartup = true ;
14
+ public enableCargoWatchOnStartup : CargoWatchOptions = 'ask' ;
13
15
14
16
private prevEnhancedTyping : null | boolean = null ;
15
17
@@ -71,9 +73,9 @@ export class Config {
71
73
}
72
74
73
75
if ( config . has ( 'enableCargoWatchOnStartup' ) ) {
74
- this . enableCargoWatchOnStartup = config . get < boolean > (
76
+ this . enableCargoWatchOnStartup = config . get < CargoWatchOptions > (
75
77
'enableCargoWatchOnStartup' ,
76
- true
78
+ 'ask'
77
79
) ;
78
80
}
79
81
}
You can’t perform that action at this time.
0 commit comments