Giter Club home page Giter Club logo

vscode-terraform's Introduction

Terraform Extension for Visual Studio Code

The HashiCorp Terraform Extension for Visual Studio Code (VS Code) with the Terraform Language Server adds editing features for Terraform files such as syntax highlighting, IntelliSense, code navigation, code formatting, module explorer and much more!

Quick Start

Get started writing Terraform configurations with VS Code in three steps:

  • Step 1: If you haven't done so already, install Terraform

  • Step 2: Install the Terraform Extension for VS Code.

  • Step 3: To activate the extension, open any folder or VS Code workspace containing Terraform files. Once activated, the Terraform language indicator will appear in the bottom right corner of the window.

New to Terraform? Read the Terraform Learning guides

See Usage for more detailed getting started information.

Read the Troubleshooting Guide for answers to common questions.

Features

IntelliSense and Autocomplete

IntelliSense is a general term for a variety of code editing features including: code completion, parameter info, quick info, and member lists. IntelliSense features are sometimes called by other names such as autocomplete, code completion, and code hinting.

For Terraform constructs like resource and data, labels, blocks and attributes are auto completed both at the root of the document and inside other blocks. This also works for Terraform modules that are installed in the workspace, attributes and other constructs are autocompleted.

Note: If there are syntax errors present in the document upon opening, intellisense may not provide all completions. Please fix the errors and reload the document and intellisense will return. See hcl-lang#57 for more information.

Invoking intellisense is performed through the keyboard combination for your platform and the results depend on where the cursor is placed.

If the cursor is at the beginning of a line and no other characters are present, then a list of constructs like data, provider, resource, etc are shown.

If inside a set of quotes or inside a block, the extension provides context specific completions appropriate for the location. For example, inside a resource block attributes for a given provider are listed.

Combining editor.suggest.preview with the pre-fill required fields setting will provide inline snippet suggestions for blocks of code:

Completing the snippet allows you to tab complete through each attribute and block.

Syntax Validation

Terraform configuration files are validated when opened and on change, and invalid code is marked with diagnostics.

HCL syntax is checked for e.g. missing control characters like }, " or others in the wrong place.

Enhanced validation of selected Terraform language constructs in both *.tf and *.tfvars files based on detected Terraform version and provider versions is also provided. This can highlight deprecations, missing required attributes or blocks, references to undeclared variables and more, as documented.

The enhanced validation feature is enabled by default but can be disabled using the following setting:

"terraform.validation.enableEnhancedValidation": false

The extension also provides validation through terraform validate. This can be triggered via command palette. Unlike the other validation methods, this one requires the Terraform CLI installed and a previous successful run of terraform init (i.e. local installation of all providers and modules) to function correctly. It is the slowest method, but the most thorough - i.e. it will catch the most mistakes.

Syntax Highlighting

Terraform syntax highlighting recognizes language constructs from Terraform version 0.12 to 1.X. Terraform providers, modules, variables and other high-level constructs are recognized, as well as more complex code statements like for loops, conditional expressions, and other complex expressions.

Some language constructs will highlight differently for older versions of Terraform that are incompatible with newer ways of expressing Terraform code. In these cases we lean toward ensuring the latest version of Terraform displays correctly and do our best with older versions.

Code Navigation

While editing, you can right-click different identifiers to take advantage of several convenient commands

  • Go to Definition (F12) navigates to the code that defines the construct where your cursor is. This command is helpful when you're working with Terraform modules and variables defined in other files than the currently opened document.
  • Peek Definition (Alt+F12) displays the relevant code snippet for the construct where your cursor is directly in the current editor instead of navigating to another file.
  • Go to Declaration navigates to the place where the variable or other construct is declared.
  • Peek Declaration displays the declaration directly inside the current editor.

Code Formatting

This extension utilizes terraform fmt to rewrite an open document to a canonical format and style. This command applies a subset of the Terraform language style conventions, along with other minor adjustments for readability.

See the Formatting Configuration section for information on how to configure this feature.

Code Snippets

The extension provides several snippets to accelerate adding Terraform code to your configuration files:

  • fore - For Each
  • module - Module
  • output - Output
  • provisioner - Provisioner
  • vare - Empty variable
  • varm - Map Variable

HCP Terraform Integration

Every time you have to switch away from your code, you risk losing momentum and the context about your tasks. Previously, Terraform users needed to have at least two windows open – their editor and a web page – to develop Terraform code. The editor contains all of the Terraform code they are working on, and the web page has the HCP Terraform workspace loaded. Switching back and forth between the HCP Terraform website and the text editor can be a frustrating and fragmented experience.

The HCP Terraform Visual Studio Code integration improves user experience by allowing users to view workspaces directly from within Visual Studio Code. Users can view the status of current and past runs and inspect detailed logs – without ever leaving the comfort of their editor.

To start using HCP Terraform with VS Code, open the new HCP Terraform sidebar and click "Login to HCP Terraform". You can login using a stored token from the Terraform CLI, an existing token you provide, or open the HCP Terraform website to generate a new token.

Once logged in, you are prompted to choose which Organization to view workspaces in.

Now that your Organization is chosen, the Workspace view populates with all workspaces your token has permission to view. At a glance, you can see the last run status of each Workspace. Hovering over a workspace shows detailed information about each workspace.

Selecting a workspace populates the Run view with a list of runs for that workspace. At a glance, you can see the status of each Run, and hover over each for more detailed information.

If a Run has been Planned or Applied, you can view the raw log for each by expanding the Run then selecting the 'View Raw Log' button for either the Plan or Apply.

To sign out or log out of your HCP Terraform session, click the Accounts icon next to the Settings icon in the Activity Bar and select "Sign Out":

This will clear the currently saved token and allow you to login using a different token.

Terraform Module and Provider Explorer

List Terraform modules used in the current open document in the Explorer Pane, or drag to the Side Bar pane for an expanded view.

Each item shows an icon indicating where the module comes from (local filesystem, git repository, or Terraform Registry).

If the module comes from the Terraform Registry, a link to open the documentation in a browser is provided.

List Terraform providers used in the current open document in the Explorer Pane, or drag to the Side Bar pane for an expanded view.

Terraform Commands

The extension provides access to several Terraform commands through the Command Palette:

  • Terraform: init
  • Terraform: init current folder
  • Terraform: validate
  • Terraform: plan

Requirements

The Terraform VS Code extension bundles the Terraform Language Server and is a self-contained install.

The extension does require the following to be installed before use:

  • VS Code v1.86 or greater
  • Terraform v0.12 or greater

Platform Support

The extension should work anywhere VS Code itself and Terraform 0.12 or higher is supported. Our test matrix includes the following:

  • Windows Server 2022 with Terraform v1.6
  • macOS 12 with Terraform v1.6
  • macOS 11 with Terraform v1.6
  • Ubuntu 22.04 with Terraform v1.6

Intellisense, error checking and other language features are supported for Terraform v0.12 and greater.

Syntax highlighting targets Terraform v1.0 and greater. Highlighting 0.12-0.15 configuration is done on a best effort basis.

Usage

VS Code Workspace support

It is a common pattern to have separate folders containing related Terraform configuration that are not contained under one root folder. For example, you have a main Terraform folder containing the configuration for a single application and several module folders containing encapsulated code for configuring different parts of component pieces. You could open each folder in a separate VS Code window, and bounce between each window to author your changes.

A better approach is to use VS Code Workspaces. Using our example above, open the main Terraform folder first, then use Add Folder to workspace to add the dependent module folders. A single VS Code window is used and all Terraform files are available to author your changes. This uses a single terraform-ls process that has an understanding of your entire project, allowing you to use features like Go to Symbol and Reference counts across your project.

Single file support

Opening a single Terraform configuration file inside VS Code is currently not supported. We see this approach most commonly attempted by users of terminal editors like vim, where it is common to edit a single file at a time.

The Terraform VS Code extension works best when it has the full context of a Terraform project where it can parse the referenced files and provide the expected advanced language features.

The recommended workflow is to instead open the containing folder for the desired Terraform file inside a single VS Code editor window, then navigate to the desired file. This seems counter-intuitive when you only want to edit a single file, but this allows the extension to understand the Terraform setup you are using and provide accurate and helpful intellisense, error checking, and other language features.

Refresh Intellisense

The extension will pick up new schema for Terraform providers you reference in your configuration files automatically whenever anything changes inside .terraform.

To provide the extension with an up-to-date schema for the Terraform providers used in your configuration:

  1. Open any folder or VS Code workspace containing Terraform files.
  2. Open the Command Palette and run Terraform: init current folder or perform a terraform init from the terminal.

Remote Extension support

The Visual Studio Code Remote - WSL extension lets you use the Windows Subsystem for Linux (WSL) as your full-time development environment right from VS Code. You can author Terraform configuration files in a Linux-based environment, use Linux-specific toolchains and utilities from the comfort of Windows.

The Remote WSL extension runs the HashiCorp Extension and other extensions directly in WSL so you can edit files located in WSL or the mounted Windows filesystem (for example /mnt/c) without worrying about pathing issues, binary compatibility, or other cross-OS challenges.

For a detailed walkthrough for how to get started using WSL and VS Code, see https://code.visualstudio.com/docs/remote/wsl-tutorial.

Configuration

The extension does not require any initial configuration and should work out of the box. To take advantage of additional VS Code features or experimental extension features you can configure settings to customize behavior.

This extension offers several configuration options. To modify these open the VS Code Settings Editor in the UI or JSON view for user and workspace level settings, scope your settings by language, or alternatively modify the .vscode/settings.json file in the root of your working directory.

Code Completion

An experimental option can be enabled to prefill required fields when completing Terraform blocks with the following setting:

"terraform.experimentalFeatures.prefillRequiredFields": true

For example, choosing aws_alb_listener in the following block inserts a snippet in the current line with the resource block entirely filled out, containing tab stops to fill in the required values.

Combine this with editor.suggest.preview and the editor will provide inline snippet suggestions for blocks of code:

Completing the snippet allows you to tab complete through each attribute and block.

Code Lens

Display reference counts above top level blocks and attributes

"terraform.codelens.referenceCount": true

Note: This feature impacts extension performance when opening folders with many modules present. If you experience slowness or high CPU utilization, open a smaller set of folders or disable this setting.

Formatting

To enable automatic formatting, it is recommended that the following be added to the extension settings for the Terraform extension:

"[terraform]": {
  "editor.defaultFormatter": "hashicorp.terraform",
  "editor.formatOnSave": true,
  "editor.formatOnSaveMode": "file"
},
"[terraform-vars]": {
  "editor.defaultFormatter": "hashicorp.terraform",
  "editor.formatOnSave": true,
  "editor.formatOnSaveMode": "file"
}

It is recommended to set editor.defaultFormatter to ensure that VS Code knows which extension to use to format your files. It is possible to have more than one extension installed which claim a capability to format Terraform files.

When using the editor.formatOnSaveMode setting, only file is currently supported. The modifications or modificationsIfAvailable settings use the currently configured SCM to detect file line ranges that have changed and send those ranges to the formatter. The file setting works because terraform fmt was originally designed for formatting an entire file, not ranges. If you don't have an SCM enabled for the files you are editing, modifications won't work at all. The modificationsIfAvailable setting will fall back to file if there is no SCM and will appear to work sometimes.

If you want to use editor.codeActionsOnSave with editor.formatOnSave to automatically format Terraform files, use the following configuration:

"editor.formatOnSave": true,
"[terraform]": {
  "editor.defaultFormatter": "hashicorp.terraform",
  "editor.formatOnSave": false,
  "editor.codeActionsOnSave": {
    "source.formatAll.terraform": true
  },
},
"[terraform-vars]": {
  "editor.defaultFormatter": "hashicorp.terraform",
  "editor.formatOnSave": false,
  "editor.codeActionsOnSave": {
    "source.formatAll.terraform": true
  },
}

This will keep the global editor.formatOnSave for other languages you use, and configure the Terraform extension to only format during a codeAction sweep.

Note: Ensure that the terraform binary is present in the environment PATH variable. If the terraform binary cannot be found, formatting will silently fail.

Validation

An experimental validate-on-save option can be enabled with the following setting:

"terraform.experimentalFeatures.validateOnSave": true

This will create diagnostics for any elements that fail validation. You can also run terraform validate by issuing the Terraform: validate in the command palette.

Multiple Workspaces

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.languageServer.rootModules": [
  "/module1",
  "/module2"
]

If you want to automatically search root modules in your workspace and exclude some folders, you can configure the language server settings to identify them.

"terraform.languageServer.excludeRootModules": [
  "/module3",
  "/module4"
]

If you want to automatically ignore certain directories when terraform-ls indexes files, add the folder names to this setting:

 "terraform.languageServer.ignoreDirectoryNames": [
   "folder1",
   "folder2"
 ]

Terraform command options

You can configure the path to the Terraform binary used by terraform-ls to perform operations inside the editor by configuring this setting:

"terraform.languageServer.terraform.path": "C:/some/folder/path"

You can override the Terraform execution timeout by configuring this setting:

"terraform.languageServer.terraform.timeout": "30"

You can set the path Terraform logs (TF_LOG_PATH) by configuring this setting:

"terraform.languageServer.terraform.logFilePath": "C:/some/folder/path/log-{{varname}}.log"

Supports variables (e.g. timestamp, pid, ppid) via Go template syntax {{varname}}

Telemetry

We use telemetry to send error reports to our team, so we can respond more effectively. You can configure VS Code to send all telemetry, just crash telemetry, just errors or turn it off entirely by configuring "telemetry.telemetryLevel" to your desired value. You can also monitor what's being sent in your logs.

Known Issues

  • If there are syntax errors present in the document upon opening, intellisense may not provide all completions. Run Terraform: validate and fix validation errors, then reload the document and intellisense will work again. Potential solutions for this are being investigated in See hcl-lang#57 for more information.
  • Completion inside incomplete blocks, such as resource "here (without the closing quote and braces) is not supported. You can complete the 1st level blocks though and that will automatically trigger subsequent completion for e.g. resource types. See terraform-ls#57 for more information.
  • A number of different folder configurations (specifically when your root module is not a parent to any submodules) are not yet supported. More information available in (terraform-ls#32)

Terraform 0.11 compatibility

If you are using a Terraform version prior to 0.12.0, you can install the pre-transfer 1.4.0 version of this extension by following the instructions in the pin version section.

The configuration has changed from 1.4.0 to v2.X. If you are having issues with the Language Server starting, you can reset the configuration to the following:

"terraform.languageServer.enable": true,
"terraform.languageServer.args": ["serve"]

Troubleshooting

  • If you have a question about how to accomplish something with the extension, please ask on the Terraform Editor Discuss site
  • If you come across a problem with the extension, please file an issue.
  • If someone has already filed an issue that encompasses your feedback, please leave a 👍/👎 reaction on the issue
  • Contributions are always welcome! Please see our contributing guide for more details
  • If you're interested in the development of the extension, you can read about our development process

Settings Migration

Read more about changes in settings options introduced in v2.24.0.

Generate a bug report

Experience a problem? You can have VS Code open a Github issue in our repo with all the information filled out for you. Open the Command Palette and invoke Terraform: Generate Bug Report. This will inspect the VS Code version, the Terraform extension version, the terraform-ls version and the list of installed extensions and open a browser window with GitHub loaded. You can then inspect the information provided, edit if desired, and submit the issue.

Reload the extension

If you haven't seen the Problems Pane update in awhile, or hover and intellisense doesn't seem to showing up, you might not know what to do. Sometimes the Terraform extension can experience problems which cause the editor to not respond. The extension has a way of reporting the problem, but there is something you can do to get right back to working after reporting the problem: reload the Terraform extension.

You can reload the Terraform extension by opening the command palette and starting to type Reload. A list of commands will appear, select Reload Window. This will reload the Visual Studio Code window without closing down the entire editor, and without losing any work currently open in the editor.

Pin to a specific version of the extension

If you wish to install a specific version of the extension, you can choose 'Install Another version' option in the Extensions pane. This will bring up a list of prior versions for the selected extension. Choose the version you want to install from the list.

Code of Conduct

HashiCorp Community Guidelines apply to you when interacting with the community here on GitHub and contributing code to this repository.

Please read the full text at https://www.hashicorp.com/community-guidelines

Contributing

We are an open source project on GitHub and would enjoy your contributions! Consult our development guide for steps on how to get started. Please open a new issue before working on a PR that requires significant effort. This will allow us to make sure the work is in line with the project's goals.

Release History

v2.0.0 is the first official release from HashiCorp, prior releases were by Mikael Olenfalk.

The 2.0.0 release integrates a new Language Server package from HashiCorp. The extension will install and upgrade terraform-ls to continue to add new functionality around code completion and formatting. See the terraform-ls CHANGELOG for details.

In addition, this new version brings the syntax highlighting up to date with all HCL2 features, as needed for Terraform 0.12 and above.

Configuration Changes Please note that in 2.x, the configuration differs from 1.4.0, see Known Issues for more information.

See the CHANGELOG for more detailed release notes.

Credits

vscode-terraform's People

Contributors

aeschright avatar aicarmic avatar altern8tif avatar ansgarm avatar appilon avatar beandrad avatar breathingdust avatar dbanck avatar dependabot[bot] avatar glennsarti avatar haad avatar hashicorp-copywrite[bot] avatar hashicorp-tsccr[bot] avatar jackric avatar josh-padnick avatar jpogran avatar kinday avatar lawrencegripper avatar lostintangent avatar madssj avatar maglenno avatar mattfenner avatar mauve avatar njucz avatar paultyng avatar radeksimko avatar ranga543 avatar ratza avatar teraken0509 avatar xiehan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-terraform's Issues

Pressing Ctrl opens documentation

Pressing Ctrl (just Ctrl!) opens documentation.

I'd like to only happen when I Ctrl+click, as everywhere else it works.

I'm using Ubuntu 16.04.

Bug/Preference: New line added, inconsistently, between variable declarations

Steps to reproduce

If I start with this...

# The SNS topics to use for alarms when missing data, insufficient data, data has returned to OK status (health service)
variable "sns_arn_alarm" {}
variable "sns_arn_alarm_insufficient" {}
variable "sns_arn_alarm_ok" {}

Actual results

When I save the file it gets turned into this...

# The SNS topics to use for alarms when missing data, insufficient data, data has returned to OK status (health service)
variable "sns_arn_alarm" {}

variable "sns_arn_alarm_insufficient" {}
variable "sns_arn_alarm_ok" {}

Expected results

Personally, I'd like the lot to stay together, but if there are reasons to require the new line then I'd prefer it to be applied consistently, like this...

# The SNS topics to use for alarms when missing data, insufficient data, data has returned to OK status (health service)
variable "sns_arn_alarm" {}

variable "sns_arn_alarm_insufficient" {}

variable "sns_arn_alarm_ok" {}

Auto Save and Auto Format conflict

This is more of a feature request than an actual bug, but with Auto Save enabled in vscode and auto formatting on in Terrafom there are some issues.

When typing in a new line, pausing for a second will cause auto format to run and will move incomplete code around, remove lines that are needed, etc. I've found that if I put in an illegal char, that will prevent auto formatting to run until I'm ready for it to auto format.

Both features are great, but it would be nice if there was a delay on auto formatting that could be configured or invoke formatting on keystroke or button vs on save.

Option to disable fmt for tfvars file

The terraform fmt runner is neat, but on I would prefer to have an option to disable it for tfvars file. It makes them look really ugly with spaces between all the variables.

Terraform validation should support configuration

All of these should be configurable:

Usage: terraform validate [options] [dir]

  Validate the terraform files in a directory. Validation includes a
  basic check of syntax as well as checking that all variables declared
  in the configuration are specified in one of the possible ways:

      -var foo=...
      -var-file=foo.vars
      TF_VAR_foo environment variable
      terraform.tfvars
      default value

  If dir is not specified, then the current directory will be used.

Options:

  -check-variables=true If set to true (default), the command will check
                        whether all required variables have been specified.

  -no-color             If specified, output won't contain any color.

  -var 'foo=bar'        Set a variable in the Terraform configuration. This
                        flag can be set multiple times.

  -var-file=foo         Set variables in the Terraform configuration from
                        a file. If "terraform.tfvars" is present, it will be
                        automatically loaded if this flag is not specified.

Path expansion for terraform binaries broken

It looks like #50 broke my configuration (formatting, linting, etc no longer work) since my binaries are in my home dir (e.g. ~/bin/terraform) and child_process.execFile doesn't spawn a shell

Changing that to /real/path/to/bin/terraform gets things going again, but it would be nice to support at least home directory expansion again.

not formatting on save

Hi,

formatting on save stopped working in the last few days.

using vscode Version 1.19.0
plugin 0.0.20
Terraform v0.11.1

Formatting is not working

I have this settings on my user settings:

    "[terraform]": {
        "editor.formatOnSave": true
    },
    "editor.formatOnSave": true,

And this on my workspace settings:

 "files.associations": {
        "**/terraform/*/*.tf": "terraform",
        "*.tf": "terraform",
        "*.tfstate": "json"
    ,}

I cannot get format on save to work and i i choose the command directly on the palette:

There is no formatter for 'terraform'-files installed.

Terraform: Validate and Terraform:Lint give similar results

My configuration:

"code --version" output: 1.21.0
9a199d77c82fcb82f39c68bb33c614af01c111ba
x64

Extension version: 0.0.23

Thanks!

Autocomplete & syntax highlighting not working

Hello,

Thanks for the extension. I was looking forward to use it to reduce a lot of typing with terraform.
I was trying this plugin on a mac (v10.13.33), VSCode (v1.20) and Terraform (v 0.11.3) and the autocomplete or syntax highlighting doesn't work at all.

Tried to reinstall this and VS Code as well but no luck.

Then I tried to install the other Terraform autocomplete extension (which is in beta) and it works as expected.

Can you please advise if I am missing something?

image

Incorrectly highlighting Strings inside maps

In the below screenshot I'd expect the strings inside the map to be colored green as well (I'm using the Kimbie Dark theme).

image

Later edit: the comments inside maps are also colored incorrectly

"Sorry, but there is no formatter for 'terraform'-files installed." with portable ZIP instance of VSCode

I am running VSCode (x64) v1.18.0 with v0.0.19 of this extension.

VSCode is being run from the extracted contents of a portable ZIP. It is not "installed" on the machine, just unzipped from the portable ZIP into a directory and executed from there.

I'm running the portable ZIP version due to a lack of admin rights, on a client-provided laptop for my current project. Admin rights may or may not be attainable, so I have to work without them for the time being.

When I choose the "Format Document" option from the command palette, I get the following error:

Sorry, but there is no formatter for 'terraform'-files installed.

I have also tried setting the path to the terraform.exe in VSCode settings like so:

    "terraform.path": "C:\\bin\\terraform.exe",

This doesn't make any difference, unfortunately.

terraform.format [on-save]: Failed: 'Error: write EPIPE'

Multiple Win10 machines running VSCode and Terraform 0.23.
The linter does not seem happy, as all on-save events and validate fail.
terraform.validate and terraform.lint simply report 'Failed', while the on-save event reports Error: write EPIPE.

Any ideas if there are known incompatibilities that prevent the plugin from doing validation, linting?

Variable interpolation in quotes does not auto-close braces

I am trying to reference a variable in a .tf file in my project. I have two quotes already typed out and then I type ${. At this point, I would expect a close-brace character (}) to automatically be inserted at this point, but it isn't. I know (annoyingly) have to type in that character.

It would be great if this extension supported this auto-closing, like it is suggested in the README. Other IDEs support this, such as Jetbrains.

How are you keeping docs up to date?

Hey there,

I created another vscode plugin for autocomplete since I couldn't get yours working, but now I see with the recent updates that yours is way better than what I had so I'm going to bow out and leave this with you, however one of my challenges was keeping the documentation up to date and I was wondering how you were doing it?

I had started this: https://github.com/erd0s/terraform-scrape which I used to get all the data from the online docs, if you don't already have something in place I'd be happy to modify what I have to fit with your plugin, either way I'd be interested to know how you're doing it because it killed me when I was trying!

Cheers

Fmt on save not working with vscode 1.11.1

Hi,

Thanks for the good work on this extension.
Since the last update of vscode, the fmt on save doesn't work anymore. I have update to 0.0.7 and added "terraform.formatOnSave": true to my use settings.

My coworker has the same problem.

Laurent.

Code folding of resources does not correctly handle inline HEREDOC blocks

When viewing a resource in a Terraform file, if it contains a HEREDOC block (for example, an IAM policy), the code folding doesn't work - the closing curly brace is correctly matched but when folding the resource the HEREDOC block remains unfolded.

Unfolded:

image

Folded:

image

VSCode version: 1.19.2, x64, Linux (Ubuntu 16.04)
plugin version: mauve.terraform 0.0.20

resource auto-completion

Hi,

I'm wondering what your thoughts are on extending auto-completion for resources and data sources. I did a quick hack to test this out (screenshot below). Do you have input / would you consider a PR to accomplish this?

screen shot 2017-12-13 at 7 37 08 pm

A few thoughts of mine, in no particular order:

  • I'm collecting resource types by scraping https://www.terraform.io/docs/index.html. the vim-terraform project seems to accomplish the same by cloning github repos that match terraform-provider-*, and searching for resource definitions in the source.
  • CompletionItem.documentation can present abbreviated documentation and link to terraform.io
  • It may be possible to auto-populate required properties, but I haven't given this much thought.

Curious to have your thoughts and interested in putting a PR together if this approach seems reasonable.

Do not format tfvariable file

Seems like with the version of 0.0.20 the "terraform.formatVarsOnSave" does no longer exist.
How with the new version I can disable formatting for tfvars files but leave it for tf files?

thank you

extra lines, removal of tabs on latest build

i've been using this for a while now - its great.
but i've noticed recently on save, all of my tabs get deleted and every line in the document is spaced by 2.
removing the module corrects the issue
This happens as soon as i save my document

eg:

variable "foo"                      {}
variable "bar"                      {}

becomes
variable "foo" {}


variable "bar" {}

Disable `terraform.formatOnSave` by default

In our team, almost everyone was surprised that .tf files get reformatted on each save. It took us some time to realize that there is the terraform.formatOnSave config option. A small suggestion would be to ship the extension with auto-formatting disabled by default.

Add an option to force hcl hightlighting to any files

Hi,

As mention in #16. I remembered why I had installed HCL extension.

Without it I can't force the syntax highlighting on any file extension.

I have some *.hcl files but with *ctmpl extension (for consul template). With the HCL extension I can choose to force vscode to recognize those files as hcl and without I can't:
screenshot 2017-04-13 07 38 30

Do you think you can make it?
It would be great.

Laurent

Support #region #endregion for code folding

These are supported in core vscode for some languages (https://stackoverflow.com/a/46597272/4200039 and microsoft/vscode#12146) - I suggest adding #region support.

Also if the autoformatter did not force a space before the trailing #endregion comment I'd prefer that.

I tried adding something like https://github.com/Microsoft/vscode/blob/6c421d85528d4ddb37dcb167b7a442e348f51378/extensions/javascript/javascript-language-configuration.json to https://github.com/mauve/vscode-terraform/blob/master/syntaxes/terraform.json and https://github.com/mauve/vscode-terraform/blob/master/terraform.configuration.json but it didn't work.

terraform fmt isn't called

Hello,

I'm looking at the config, and I would expect that terraform fmt be run when I execute a save: command s on the Mac.

    "enable": true,
    "ignoreExtensionsOnSave": [
      ".tfsmurf"
    ],
    "formatOnSave": true
   },

I am using VS Code 1.22.2, plugin 0.0.23 of the plugin, and am running OSX 10.13.4, this was previously working, so I'm not sure why it stopped. I don't see any obvious mentions in the Console log or the Dev Tools. Nothing is registered when I execute command s. Running terraform fmt from bash does what I expect.

Configure extensions to apply formatting to

Great plugin, thanks!

It would be great to allow for other extensions. For example, we use jinja2 templates to generate our terraform .tf files, so in source control our file extensions are .tf.tpl, which this plugin ignores.

It would be nice to be able to add that extension in a configuration setting, or if the plugin applied this formatting to any file extension containing .tf in it.

🤷‍♂️

Thanks again!

String highlighting error

Since the most recent update (0.8 or 0.10 not to sure), it seems to have introduced a bug in the syntax highlighting of strings.

The attached screenshot explains it better:

screen shot 2017-04-13 at 08 15 46

After the DEFINITION string ends, the highlighting is treating the rest of the file as a string, when it is not.

The Terraform template is definitely valid and it's not an escaping issue, the problem first occurred after I updated the plugin.

Add syntax highlighting for .tfstate files

Not a big deal, but sometimes you want to poke around and look at the .tfstate files that Terraform manages. Apparently, they are just plain JSON, so it would be neat if this extension instructed VS Code accordingly.

When terraform.indexing.enabled is true, Code UI freezes on Ubuntu

Indexing is now enabled by default since vscode-terraform 0.0.21: 7d170c6#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R149

This change seems to freeze Code UI on my system (Ubuntu 17.10 with code 1.21.0-1520420608) where terraform-index is not installed.

Work-around, start Code with code --disable-extensions and add "terraform.indexing.enabled": false to user settings.

As soon as I change terraform.indexing.enabled from false to true, code UI freezes.

settings json - objenious - visual studio code_291

Here are some logs when that happens:

==> /home/pdecat/.config/Code/logs/20180309T110358/exthost1.log <==                                    
[2018-03-09 13:07:13.692] [exthost1] [info] ExtensionService#_doActivateExtension mauve.terraform {"startup":false,"activationEvent":"onLanguage:terraform"}
[2018-03-09 13:07:13.692] [exthost1] [info] ExtensionService#loadCommonJSModule /home/pdecat/.vscode/extensions/mauve.terraform-0.0.21/out/src/extension
==> /home/pdecat/.config/Code/logs/20180309T110358/main.log <==                                                                                                                                                
[2018-03-09 13:04:28.563] [main] [info] update#setState checking for updates                           
[2018-03-09 13:04:29.238] [main] [info] update#setState idle                                           
[2018-03-09 13:07:46.637] [main] [error] [VS Code]: detected unresponsive                              

Note: only the main view is frozen, menu and developer tools still work.

on osx, cmd key shortcut

This is more of a question than an issue; is there any way to disable the "cmd" shortcut that automatically opens the browser with the terraform documentation for the resource that the cursor is in in the editor?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.