From a781b0047b35a02d92f4394cb7732a2d0e23cc51 Mon Sep 17 00:00:00 2001 From: Audrey Eschright Date: Fri, 26 Jun 2020 12:37:47 -0700 Subject: [PATCH 1/5] Add setting for workspace root modules --- out/extension.js | 26 +++++++++++++++++--------- out/extension.js.map | 2 +- package.json | 5 +++++ src/extension.ts | 26 +++++++++++++++++--------- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/out/extension.js b/out/extension.js index 1ff172671..cb0684a1e 100644 --- a/out/extension.js +++ b/out/extension.js @@ -46,15 +46,17 @@ function activate(context) { stopLsClient(); })); context.subscriptions.push(vscode.workspace.onDidChangeConfiguration((event) => { - 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'); - } - }); })); if (useLs) { return installThenStart(context, config); @@ -92,11 +94,17 @@ function startLsClient(cmd, config) { const binaryName = cmd.split("/").pop(); let serverOptions; let serverArgs = config.get("languageServer.args"); + let additionalArgs; + if (config.has("rootModules")) { + const rootModules = 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 = { command: cmd, - args: serverArgs, + args: args, options: {} }; serverOptions = { diff --git a/out/extension.js.map b/out/extension.js.map index 0278536ad..a6fb20b38 100644 --- a/out/extension.js.map +++ b/out/extension.js.map @@ -1 +1 @@ -{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src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S,CAAC;aAC/D;YACD,aAAa,EAAE,KAAK;YACpB,qBAAqB,EAAE,CAAC,CAAC,cAAc;SACvC,CAAC;QAEF,MAAM,GAAG,IAAI,sCAAc,CAC1B,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,aAAa,CACb,CAAC;QAEF,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CAAA;AAED,SAAS,YAAY;IACpB,IAAI,CAAC,MAAM,EAAE;QACZ,OAAO;KACP;IACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC"} \ No newline at end of file +{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAiC;AACjC,iEAK+B;AAE/B,uEAAoE;AAGpE,IAAI,MAAsB,CAAC;AAE3B,SAAgB,QAAQ,CAAC,OAAgC;IACxD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAE9D,gCAAgC;IAChC,IAAI,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAAE;QACzC,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAC7B,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,EAC7D,IAAI,CACJ,CAAA;KACD;IACD,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IAElD,qBAAqB;IAErB,yDAAyD;IACzD,sHAAsH;IACtH,kEAAkE;IAClE,8BAA8B;IAC9B,6DAA6D;IAC7D,iDAAiD;IACjD,OAAO;IACP,6DAA6D;IAC7D,iDAAiD;IACjD,OAAO;IACP,iEAAiE;IACjE,qDAAqD;IACrD,MAAM;IACN,KAAK;IAEL,k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,CAAC,aAAa,CAAC,CAAC;YACxD,cAAc,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,MAAM,EAAE,CAAC,CAAC;SACrE;QACD,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAE/C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC5D,KAAK,CAAC,UAAU,CAAC,8BAA8B,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAExE,MAAM,UAAU,GAAe;YAC9B,OAAO,EAAE,GAAG;YACZ,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,EAAE;SACX,CAAA;QACD,aAAa,GAAG;YACf,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,UAAU;SACjB,CAAC;QAEF,MAAM,aAAa,GAA0B;YAC5C,gBAAgB,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;YAC7D,WAAW,EAAE;gBACZ,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,CAAC;aAC/D;YACD,aAAa,EAAE,KAAK;YACpB,qBAAqB,EAAE,CAAC,CAAC,cAAc;SACvC,CAAC;QAEF,MAAM,GAAG,IAAI,sCAAc,CAC1B,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,aAAa,CACb,CAAC;QAEF,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CAAA;AAED,SAAS,YAAY;IACpB,IAAI,CAAC,MAAM,EAAE;QACZ,OAAO;KACP;IACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index bc730618c..bc1f6ae39 100644 --- a/package.json +++ b/package.json @@ -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" } } }, diff --git a/src/extension.ts b/src/extension.ts index 633f4f406..d46f5f70f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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'); - } - }); } ) ); @@ -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 = { From fd77f375f26cbcc1805f62b8c8e68f09b7452f0c Mon Sep 17 00:00:00 2001 From: Audrey Eschright Date: Mon, 29 Jun 2020 12:08:44 -0700 Subject: [PATCH 2/5] Update package.json Co-authored-by: Paul Tyng --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index bc1f6ae39..72eb524c4 100644 --- a/package.json +++ b/package.json @@ -138,6 +138,10 @@ "terraform.rootModules": { "scope": "resource", "type": "array", + "items": { + "type": "string" + }, + "default": [] "description": "Per-workspace list of module directories for the language server to read" } } From dcceca6224841863d5bb6654c0ffa7e46693b233 Mon Sep 17 00:00:00 2001 From: Audrey Eschright Date: Thu, 2 Jul 2020 11:17:22 -0700 Subject: [PATCH 3/5] Update package.json Co-authored-by: Paul Tyng --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 72eb524c4..9b04667cc 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,7 @@ "items": { "type": "string" }, - "default": [] + "default": [], "description": "Per-workspace list of module directories for the language server to read" } } From d2f44384842d69f6740dd53bc23b0a60fdf2443a Mon Sep 17 00:00:00 2001 From: Audrey Eschright Date: Wed, 8 Jul 2020 11:06:12 -0700 Subject: [PATCH 4/5] Update namespace for language server config --- out/extension.js | 17 +++++++---------- out/extension.js.map | 2 +- package.json | 2 +- src/extension.ts | 18 +++++++----------- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/out/extension.js b/out/extension.js index cb0684a1e..623512561 100644 --- a/out/extension.js +++ b/out/extension.js @@ -46,7 +46,7 @@ function activate(context) { stopLsClient(); })); context.subscriptions.push(vscode.workspace.onDidChangeConfiguration((event) => { - if (event.affectsConfiguration("terraform")) { + if (event.affectsConfiguration("terraform") || event.affectsConfiguration("terraform-ls")) { const reloadMsg = "Reload VSCode window to apply language server changes"; vscode.window.showInformationMessage(reloadMsg, "Reload").then((selected) => { if (selected === "Reload") { @@ -92,19 +92,15 @@ function installThenStart(context, config) { function startLsClient(cmd, config) { return __awaiter(this, void 0, void 0, function* () { const binaryName = cmd.split("/").pop(); + const lsConfig = vscode.workspace.getConfiguration("terraform-ls"); + const serverArgs = config.get("languageServer.args"); let serverOptions; - let serverArgs = config.get("languageServer.args"); - let additionalArgs; - if (config.has("rootModules")) { - const rootModules = config.get("rootModules"); - additionalArgs = rootModules.map(module => `-root-module=${module}`); - } - const args = serverArgs.concat(additionalArgs); + let initializationOptions = { rootModulePaths: lsConfig.get("rootModules") }; const setup = vscode.window.createOutputChannel(binaryName); - setup.appendLine(`Launching language server: ${cmd} ${args.join(" ")}`); + setup.appendLine(`Launching language server: ${cmd} ${serverArgs.join(" ")}`); const executable = { command: cmd, - args: args, + args: serverArgs, options: {} }; serverOptions = { @@ -116,6 +112,7 @@ function startLsClient(cmd, config) { synchronize: { fileEvents: vscode.workspace.createFileSystemWatcher('**/*.tf') }, + initializationOptions: initializationOptions, outputChannel: setup, revealOutputChannelOn: 4 // hide always }; diff --git a/out/extension.js.map b/out/extension.js.map index a6fb20b38..e06e97a8f 100644 --- a/out/extension.js.map +++ b/out/extension.js.map @@ -1 +1 @@ -{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAiC;AACjC,iEAK+B;AAE/B,uEAAoE;AAGpE,IAAI,MAAsB,CAAC;AAE3B,SAAgB,QAAQ,CAAC,OAAgC;IACxD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAE9D,gCAAgC;IAChC,IAAI,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAAE;QACzC,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAC7B,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,EAC7D,IAAI,CACJ,CAAA;KACD;IACD,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IAElD,qBAAqB;IAErB,yDAAyD;IACzD,sHAAsH;IACtH,kEAAkE;IAClE,8BAA8B;IAC9B,6DAA6D;IAC7D,iDAAiD;IACjD,OAAO;IACP,6DAA6D;IAC7D,i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ACD,aAAa,GAAG;YACf,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,UAAU;SACjB,CAAC;QAEF,MAAM,aAAa,GAA0B;YAC5C,gBAAgB,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;YAC7D,WAAW,EAAE;gBACZ,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,CAAC;aAC/D;YACD,qBAAqB,EAAE,qBAAqB;YAC5C,aAAa,EAAE,KAAK;YACpB,qBAAqB,EAAE,CAAC,CAAC,cAAc;SACvC,CAAC;QAEF,MAAM,GAAG,IAAI,sCAAc,CAC1B,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,aAAa,CACb,CAAC;QAEF,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CAAA;AAED,SAAS,YAAY;IACpB,IAAI,CAAC,MAAM,EAAE;QACZ,OAAO;KACP;IACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index 9b04667cc..fd5082c51 100644 --- a/package.json +++ b/package.json @@ -135,7 +135,7 @@ "trace.server": "off" } }, - "terraform.rootModules": { + "terraform-ls.rootModules": { "scope": "resource", "type": "array", "items": { diff --git a/src/extension.ts b/src/extension.ts index d46f5f70f..3f46bcc79 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -58,7 +58,7 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push( vscode.workspace.onDidChangeConfiguration( (event: vscode.ConfigurationChangeEvent) => { - if (event.affectsConfiguration("terraform")) { + if (event.affectsConfiguration("terraform") || event.affectsConfiguration("terraform-ls")) { const reloadMsg = "Reload VSCode window to apply language server changes"; vscode.window.showInformationMessage(reloadMsg, "Reload").then((selected) => { if (selected === "Reload") { @@ -103,22 +103,17 @@ async function installThenStart(context: vscode.ExtensionContext, config: vscode async function startLsClient(cmd: string, config: vscode.WorkspaceConfiguration) { const binaryName = cmd.split("/").pop(); + const lsConfig = vscode.workspace.getConfiguration("terraform-ls"); + const serverArgs: string[] = config.get("languageServer.args"); 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); + let initializationOptions = { rootModulePaths: lsConfig.get("rootModules") }; const setup = vscode.window.createOutputChannel(binaryName); - setup.appendLine(`Launching language server: ${cmd} ${args.join(" ")}`); + setup.appendLine(`Launching language server: ${cmd} ${serverArgs.join(" ")}`); const executable: Executable = { command: cmd, - args: args, + args: serverArgs, options: {} } serverOptions = { @@ -131,6 +126,7 @@ async function startLsClient(cmd: string, config: vscode.WorkspaceConfiguration) synchronize: { fileEvents: vscode.workspace.createFileSystemWatcher('**/*.tf') }, + initializationOptions: initializationOptions, outputChannel: setup, revealOutputChannelOn: 4 // hide always }; From a3e478aa2722473d89ce004a75e78d53d3f13e8d Mon Sep 17 00:00:00 2001 From: Audrey Eschright Date: Mon, 13 Jul 2020 16:27:58 -0700 Subject: [PATCH 5/5] Document root module setting --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 8e5012044..c48d615b2 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,18 @@ The HashiCorp Terraform Visual Studio Code (VS Code) extension adds syntax highl - Closes braces and quotes - Includes `for_each` and `variable` syntax shortcuts (`fore`, `vare`, `varm`) +## Configuration + +If you have multiple root modules in your workspace, you can configure the language server settings to identify them. Edit this through the VSCode Settings UI or add a `.vscode/settings.json` file using the following template: +``` +{ + "terraform-ls.rootModules": [ + "/module1", + "/module2" + ] +} +``` + ## Release History **v2.0.0** is the first official release from HashiCorp, prior releases were by [Mikael Olenfalk](https://github.com/mauve).