Skip to content

Commit cede979

Browse files
committed
Update extension to honor local language server settings
This commit updates the local language server invocation to honor the extension settings, for example, port or debug file. This commit removes the stopOnClientExit property as it does not make sense on the local language server and will cause issues on extension restart. This commit adds a debugFilePath setting for the local language server to direct all debug output to this file.
1 parent b795664 commit cede979

File tree

3 files changed

+32
-20
lines changed

3 files changed

+32
-20
lines changed

client/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,27 @@
8383
"puppet.languageserver.address": {
8484
"type": "string",
8585
"default": "127.0.0.1",
86-
"description": "The address of the VSCode languge sever to connect to"
86+
"description": "The IP address or hostname of the Puppet Language Server to connect to"
8787
},
8888
"puppet.languageserver.port": {
8989
"type": "integer",
9090
"default": 8081,
91-
"description": "The port of the VSCode languge sever to connect to"
92-
},
93-
"puppet.languageserver.stopOnClientExit": {
94-
"type":"boolean",
95-
"default": true,
96-
"description": "Stop the VSCode languge sever when the client disconnects"
91+
"description": "The TCP Port of the Puppet Language Server to connect to"
9792
},
9893
"puppet.languageserver.timeout": {
9994
"type": "integer",
10095
"default": 10,
101-
"description": "The timeout to connect to the VSCode languge sever"
96+
"description": "The timeout to connect to the local Puppet Language Server"
10297
},
10398
"puppet.languageserver.preLoadPuppet": {
10499
"type":"boolean",
105100
"default": true,
106-
"description": "Initalize puppet on VSCode languge start"
101+
"description": "Initalize Puppet and Facter when local Puppet Language Server starts"
102+
},
103+
"puppet.languageserver.debugFilePath": {
104+
"type":"string",
105+
"default": "",
106+
"description": "Set the local Puppet Language Server to send debug information to a file"
107107
}
108108
}
109109
}

client/src/connection.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export interface IConnectionConfiguration {
2727
type: ConnectionType;
2828
host: string;
2929
port: number;
30-
stopOnClientExit: string;
31-
timeout: string;
32-
preLoadPuppet: string;
30+
timeout: number;
31+
preLoadPuppet: boolean;
32+
debugFilePath: string;
3333
}
3434

3535
export interface IConnectionManager {
@@ -223,6 +223,18 @@ export class ConnectionManager implements IConnectionManager {
223223
return;
224224
}
225225

226+
if ((this.connectionConfiguration.host == undefined) || (this.connectionConfiguration.host == '')) {
227+
args.push('--ip=127.0.0.1');
228+
} else {
229+
args.push('--ip=' + this.connectionConfiguration.host);
230+
}
231+
args.push('--port=' + this.connectionConfiguration.port);
232+
args.push('--timeout=' + this.connectionConfiguration.timeout);
233+
if (this.connectionConfiguration.preLoadPuppet == false) { args.push('--no-preload'); }
234+
if ((this.connectionConfiguration.debugFilePath != undefined) && (this.connectionConfiguration.debugFilePath != '')) {
235+
args.push('--debug=' + this.connectionConfiguration.debugFilePath);
236+
}
237+
226238
console.log("Starting the language server with " + cmd + " " + args.join(" "));
227239
myOutputChannel.appendLine("Starting the language server with " + cmd + " " + args.join(" "));
228240
var proc = cp.spawn(cmd, args, options)

client/src/extension.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ export class ConnectionConfiguration implements IConnectionConfiguration {
1515
public type: ConnectionType = ConnectionType.Unknown;
1616
public host: string = undefined;
1717
public port: number = undefined;
18-
public stopOnClientExit: string = undefined;
19-
public timeout: string = undefined;
20-
public preLoadPuppet: string = undefined;
18+
public timeout: number = undefined;
19+
public preLoadPuppet: boolean = undefined;
20+
public debugFilePath: string = undefined;
2121

2222
constructor(context: vscode.ExtensionContext) {
2323
let config = vscode.workspace.getConfiguration('puppet');
2424

25-
this.host = config['languageserver']['address']; // '127.0.0.1';
26-
this.port = config['languageserver']['port']; // 8081;
27-
this.stopOnClientExit = config['languageserver']['stopOnClientExit']; // true;
28-
this.timeout = config['languageserver']['timeout']; // 10;
29-
this.preLoadPuppet = config['languageserver']['preLoadPuppet']; // true;
25+
this.host = config['languageserver']['address'];
26+
this.port = config['languageserver']['port'];
27+
this.timeout = config['languageserver']['timeout'];
28+
this.preLoadPuppet = config['languageserver']['preLoadPuppet'];
29+
this.debugFilePath = config['languageserver']['debugFilePath'];
3030
}
3131
}
3232

0 commit comments

Comments
 (0)