File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 86
86
"description" : " Start dcd-server at startup and complete using dcd-client."
87
87
}
88
88
}
89
- }
89
+ },
90
+ "commands" : [
91
+ {
92
+ "command" : " code-d.switchConfiguration" ,
93
+ "title" : " code-d: Switch Configuration"
94
+ }
95
+ ]
90
96
},
91
97
"scripts" : {
92
98
"vscode:prepublish" : " node ./node_modules/vscode/bin/compile" ,
Original file line number Diff line number Diff line change @@ -30,12 +30,20 @@ export function activate(context: vscode.ExtensionContext) {
30
30
context . subscriptions . push ( vscode . workspace . onDidSaveTextDocument ( document => {
31
31
if ( document . languageId != "d" )
32
32
return ;
33
- if ( config ( ) . get ( "enableLinting" , true ) )
33
+ if ( config ( ) . get ( "enableLinting" , true ) )
34
34
workspaced . lint ( document ) . then ( errors => {
35
35
diagnosticCollection . delete ( document . uri ) ;
36
36
diagnosticCollection . set ( document . uri , errors ) ;
37
37
} ) ;
38
38
} ) ) ;
39
39
40
+ vscode . commands . registerCommand ( "code-d.switchConfiguration" , ( ) => {
41
+ let self = < WorkspaceD > workspaced ;
42
+ vscode . window . showQuickPick ( self . listConfigurations ( ) ) . then ( ( config ) => {
43
+ if ( config )
44
+ self . setConfiguration ( config ) ;
45
+ } ) ;
46
+ } ) ;
47
+
40
48
console . log ( "Initialized code-d" ) ;
41
49
}
Original file line number Diff line number Diff line change @@ -274,6 +274,22 @@ export class WorkspaceD extends EventEmitter implements
274
274
this . instance . kill ( ) ;
275
275
}
276
276
277
+ listConfigurations ( ) : Thenable < string [ ] > {
278
+ return this . request ( { cmd : "dub" , subcmd : "list:configurations" } ) ;
279
+ }
280
+
281
+ setConfiguration ( config : string ) {
282
+ this . request ( { cmd : "dub" , subcmd : "set:configuration" , configuration : config } ) . then ( ( success ) => {
283
+ console . log ( "Configuration: " + config + " = " + success ) ;
284
+ if ( ! success )
285
+ vscode . window . showInformationMessage ( "No import paths available for this project. Autocompletion could be broken!" , "Switch Configuration" ) . then ( ( s ) => {
286
+ if ( s == "Switch Configuration" ) {
287
+ vscode . commands . executeCommand ( "code-d.switchConfiguration" ) ;
288
+ }
289
+ } ) ;
290
+ } ) ;
291
+ }
292
+
277
293
private mapLintType ( type : string ) : vscode . DiagnosticSeverity {
278
294
switch ( type ) {
279
295
case "warn" :
@@ -292,6 +308,13 @@ export class WorkspaceD extends EventEmitter implements
292
308
self . setupDCD ( ) ;
293
309
self . setupDScanner ( ) ;
294
310
self . setupDfmt ( ) ;
311
+ self . listConfigurations ( ) . then ( ( configs ) => {
312
+ if ( configs . length == 0 ) {
313
+ vscode . window . showInformationMessage ( "No configurations available for this project. Autocompletion could be broken!" ) ;
314
+ } else {
315
+ self . setConfiguration ( configs [ 0 ] ) ;
316
+ }
317
+ } ) ;
295
318
} , ( err ) => {
296
319
vscode . window . showErrorMessage ( "Could not initialize dub. See console for details!" ) ;
297
320
} ) ;
You can’t perform that action at this time.
0 commit comments