Skip to content

Commit f2a5367

Browse files
author
James Pogran
authored
Merge pull request #462 from glennsarti/gh-453-editor-services-advancedsettings
(GH-453) Expose advanced additional Editor Service Settings
2 parents f7372e6 + 0031dca commit f2a5367

File tree

5 files changed

+59
-9
lines changed

5 files changed

+59
-9
lines changed

package.json

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,6 @@
301301
"verbose"
302302
]
303303
},
304-
"puppet.editorService.modulePath": {
305-
"type": "string",
306-
"default": "",
307-
"description": "Additional module paths to use when starting the Editor Services. On Windows this is delimited with a semicolon, and on all other platforms, with a colon. For example C:\\Path1;C:\\Path2"
308-
},
309304
"puppet.editorService.protocol": {
310305
"type": "string",
311306
"default": "stdio",
@@ -315,6 +310,26 @@
315310
"tcp"
316311
]
317312
},
313+
"puppet.editorService.puppet.confdir": {
314+
"type": "string",
315+
"default": "",
316+
"description": "The Puppet configuration directory. See https://puppet.com/docs/puppet/latest/dirs_confdir.html for more information"
317+
},
318+
"puppet.editorService.puppet.environment": {
319+
"type": "string",
320+
"default": "",
321+
"description": "The Puppet environment to use. See https://puppet.com/docs/puppet/latest/config_print.html#environments for more information"
322+
},
323+
"puppet.editorService.puppet.modulePath": {
324+
"type": "string",
325+
"default": "",
326+
"description": "Additional module paths to use when starting the Editor Services. On Windows this is delimited with a semicolon, and on all other platforms, with a colon. For example C:\\Path1;C:\\Path2"
327+
},
328+
"puppet.editorService.puppet.vardir": {
329+
"type": "string",
330+
"default": "",
331+
"description": "The Puppet cache directory. See https://puppet.com/docs/puppet/latest/dirs_vardir.html for more information"
332+
},
318333
"puppet.editorService.tcp.address": {
319334
"type": "string",
320335
"description": "The IP address or hostname of the remote Puppet Editor Service to connect to, for example 'computer.domain' or '192.168.0.1'. Only applicable when the editorService.protocol is set to tcp"
@@ -348,6 +363,9 @@
348363
"agent"
349364
]
350365
},
366+
"puppet.editorService.modulePath": {
367+
"description": "**DEPRECATED** Please use puppet.editorService.puppet.modulePath instead"
368+
},
351369
"puppet.languageclient.protocol": {
352370
"description": "**DEPRECATED** Please use puppet.editorService.protocol instead"
353371
},

src/handlers/stdio.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class StdioConnectionHandler extends ConnectionHandler {
5252
this.logger.debug(logPrefix + 'Using environment variable RUBYLIB=' + exe.options.env.RUBYLIB);
5353
this.logger.debug(logPrefix + 'Using environment variable PATH=' + exe.options.env.PATH);
5454
this.logger.debug(logPrefix + 'Using environment variable RUBYOPT=' + exe.options.env.RUBYOPT);
55+
this.logger.debug(logPrefix + 'Editor Services will invoke with: ' + exe.command + ' ' + exe.args.join(' '));
5556

5657
let serverOptions: ServerOptions = {
5758
run: exe,

src/handlers/tcp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class TcpConnectionHandler extends ConnectionHandler {
5050
let spawn_options: cp.SpawnOptions = {};
5151
let convertedOptions = Object.assign(spawn_options, exe.options);
5252

53+
this.logger.debug(logPrefix + 'Editor Services will invoke with: ' + exe.command + ' ' + exe.args.join(' '));
5354
var proc = cp.spawn(exe.command, exe.args, convertedOptions);
5455
proc.stdout.on('data', data => {
5556
if (/LANGUAGE SERVER RUNNING/.test(data.toString())) {

src/helpers/commandHelper.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,24 @@ export class CommandEnvironmentHelper {
8989
if (vscode.workspace.workspaceFolders !== undefined) {
9090
args.push('--local-workspace=' + vscode.workspace.workspaceFolders[0].uri.fsPath);
9191
}
92-
if (settings.editorService.modulePath !== undefined && settings.editorService.modulePath !== '') {
93-
args.push('--puppet-settings=--modulepath,' + settings.editorService.modulePath);
92+
93+
// Convert the individual puppet settings into the --puppet-settings
94+
// command line argument
95+
let puppetSettings: string[] = [];
96+
[
97+
{ name: 'confdir', value: settings.editorService.puppet.confdir },
98+
{ name: 'environment', value: settings.editorService.puppet.environment },
99+
{ name: 'modulePath', value: settings.editorService.puppet.modulePath },
100+
{ name: 'vardir', value: settings.editorService.puppet.vardir }
101+
].forEach(function (item) {
102+
if (item.value !== undefined && item.value !== '') {
103+
puppetSettings.push('--' + item.name + ',' + item.value);
104+
}
105+
});
106+
if (puppetSettings.length > 0) {
107+
args.push('--puppet-settings=' + puppetSettings.join(','));
94108
}
109+
95110
if (settings.editorService.debugFilePath !== undefined && settings.editorService.debugFilePath !== '') {
96111
args.push('--debug=' + settings.editorService.debugFilePath);
97112
}

src/settings.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,21 @@ export interface IEditorServiceTCPSettings {
1212
port?: number;
1313
}
1414

15+
export interface IEditorServicePuppetSettings {
16+
confdir?: string;
17+
environment?: string;
18+
modulePath?: string;
19+
vardir?: string;
20+
}
21+
1522
export interface IEditorServiceSettings {
1623
debugFilePath?: string;
1724
docker?: IEditorServiceDockerSettings;
1825
enable?: boolean;
1926
featureflags?: string[];
20-
modulePath?: string;
2127
loglevel?: string;
2228
protocol?: ProtocolType;
29+
puppet?: IEditorServicePuppetSettings;
2330
tcp?: IEditorServiceTCPSettings;
2431
timeout?: number;
2532
}
@@ -79,6 +86,10 @@ export function legacySettings(): Map<string, Object> {
7986
let settings: Map<string, Object> = new Map<string, Object>();
8087
let value: Object = undefined;
8188

89+
// puppet.editorService.modulePath
90+
value = getSafeWorkspaceConfig(workspaceConfig, ['editorService','modulePath']);
91+
if (value !== undefined) { settings.set("puppet.editorService.modulePath", value); }
92+
8293
// puppet.languageclient.minimumUserLogLevel
8394
value = getSafeWorkspaceConfig(workspaceConfig, ['languageclient','minimumUserLogLevel']);
8495
if (value !== undefined) { settings.set("puppet.languageclient.minimumUserLogLevel", value); }
@@ -120,7 +131,6 @@ export function settingsFromWorkspace(): ISettings {
120131
enable: true,
121132
featureflags: [],
122133
loglevel: "normal",
123-
modulePath: "",
124134
protocol: ProtocolType.STDIO,
125135
timeout: 10,
126136
};
@@ -157,6 +167,7 @@ export function settingsFromWorkspace(): ISettings {
157167
// Ensure that object types needed for legacy settings exists
158168
if (settings.editorService === undefined) { settings.editorService = {}; }
159169
if (settings.editorService.featureflags === undefined) { settings.editorService.featureflags = []; }
170+
if (settings.editorService.puppet === undefined) { settings.editorService.puppet = {}; }
160171
if (settings.editorService.tcp === undefined) { settings.editorService.tcp = {}; }
161172

162173
// Retrieve the legacy settings
@@ -166,6 +177,10 @@ export function settingsFromWorkspace(): ISettings {
166177
for (const [settingName, value] of oldSettings) {
167178
switch (settingName) {
168179

180+
case "puppet.editorService.modulePath": // --> puppet.editorService.puppet.modulePath
181+
settings.editorService.puppet.modulePath = <string>value;
182+
break;
183+
169184
case "puppet.languageclient.minimumUserLogLevel": // --> puppet.editorService.loglevel
170185
settings.editorService.loglevel = <string>value;
171186
break;

0 commit comments

Comments
 (0)