Skip to content

Commit

Permalink
Add setting for workspace root modules
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschright committed Jun 26, 2020
1 parent 23f7969 commit a781b00
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
26 changes: 17 additions & 9 deletions out/extension.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion out/extension.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@
"maxNumberOfProblems": 100,
"trace.server": "off"
}
},
"terraform.rootModules": {
"scope": "resource",
"type": "array",
"description": "Per-workspace list of module directories for the language server to read"
}
}
},
Expand Down
26 changes: 17 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.workspace.onDidChangeConfiguration(
(event: vscode.ConfigurationChangeEvent) => {
if (!event.affectsConfiguration('terraform.languageServer')) {
if (event.affectsConfiguration("terraform")) {
const reloadMsg = "Reload VSCode window to apply language server changes";
vscode.window.showInformationMessage(reloadMsg, "Reload").then((selected) => {
if (selected === "Reload") {
vscode.commands.executeCommand("workbench.action.reloadWindow");
}
});
} else {
return;
}
const reloadMsg = 'Reload VSCode window to apply language server changes';
vscode.window.showInformationMessage(reloadMsg, 'Reload').then((selected) => {
if (selected === 'Reload') {
vscode.commands.executeCommand('workbench.action.reloadWindow');
}
});
}
)
);
Expand Down Expand Up @@ -104,13 +105,20 @@ async function startLsClient(cmd: string, config: vscode.WorkspaceConfiguration)
const binaryName = cmd.split("/").pop();
let serverOptions: ServerOptions;
let serverArgs: string[] = config.get("languageServer.args");
let additionalArgs: string[];

if (config.has("rootModules")) {
const rootModules: string[] = config.get("rootModules");
additionalArgs = rootModules.map(module => `-root-module=${module}`);
}
const args = serverArgs.concat(additionalArgs);

const setup = vscode.window.createOutputChannel(binaryName);
setup.appendLine(`Launching language server: ${cmd} ${serverArgs}`)
setup.appendLine(`Launching language server: ${cmd} ${args.join(" ")}`);

const executable: Executable = {
command: cmd,
args: serverArgs,
args: args,
options: {}
}
serverOptions = {
Expand Down

0 comments on commit a781b00

Please sign in to comment.