VladRassokhin / intellij-hcl

HCL language support for IntelliJ platform based IDEs
Apache License 2.0
244 stars 48 forks source link

Support Packer HCL2 #382

Open Tristan971 opened 2 years ago

Tristan971 commented 2 years ago

Prerequisites

Installation details

(all irrelevant but for completeness' sake)

IDE version: 2021.3.2 - [x] Something something can't do a collapsible element that's a checkbox apparently, but here's the info ``` IntelliJ IDEA 2021.3.2 (Ultimate Edition) Build #IU-213.6777.52, built on January 28, 2022 Licensed to [REDACTED] You have a perpetual fallback license for this version. Subscription is active until January 3, 2023. Runtime version: 11.0.13+7-b1751.25 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 11 10.0 GC: Shenandoah Pauses, Shenandoah Cycles Memory: 16384M Cores: 32 Registry: ide.balloon.shadow.size=0 ide.images.show.chessboard=true Non-Bundled Plugins: some.awesome (1.14) ski.chrzanow.foldableprojectview (1.1.1) rocks.blackcat.vcl (0.7.2) org.toml.lang (213.5744.224) org.jetbrains.plugins.go-template (213.6777.8) org.jetbrains.plugins.go (213.6777.52) org.intellij.plugins.hcl (0.7.15) net.vektah.codeglance (1.5.4) name.kropp.intellij.makefile (213.5744.224) dev.meanmail.plugin.nginx-intellij-plugin-pro (2021.4.2.213) com.jetbrains.plugins.ini4idea (213.5744.190) com.taff.plugin.orchide (2021.1.3.0-2020.1) com.intellij.nativeDebug (213.6461.6) org.openpolicyagent.opa-idea-plugin (v0.7.0-212) org.jetbrains.idea.grammar (2021.1.2) org.intellij.plugins.postcss (213.5744.190) com.databricks (1.1) mobi.hsz.idea.gitignore (4.3.0) com.intellij.kubernetes (213.6777.8) CheckStyle-IDEA (5.61.1) org.jetbrains.plugins.vue (213.6777.8) org.rust.lang (0.4.165.4438-213) deno (213.6461.6) com.jetbrains.lang.ejs (213.5744.190) com.intellij.plugins.html.instantEditing (213.5744.122) com.jetbrains.php (213.6777.58) org.jetbrains.plugins.phpstorm-remote-interpreter (213.5744.125) org.jetbrains.plugins.phpstorm-docker (213.5744.125) de.timo_reymann.intellij-mjml-support (2.0.0) com.jetbrains.twig (213.5744.224) Pythonid (213.6777.52) ru.meanmail.plugin.requirements (2022.3-2021.3) Kotlin: 213-1.6.10-release-961-IJ6777.52 ```

Terraform Configuration Files

None. In this case, I am working through using HCL2 syntax for Packer.

You can find more about the block types etc at https://www.packer.io/docs/templates/hcl_templates but it's pretty much still just HCL. Block names are obviously different (ie terraform {} -> packer {}) but it's the same design overall.

Exception

None

Expected Behavior

I would expect this plugin to have similar syntax highlighting and autocompletion for non-Packer-specific HCL.

That is, I understand that Packer isn't nearly as ubiquitous as Terraform (easy to see when this is seemingly the first issue here mentioning it 😅), so it's understandable that this plugin doesn't offer first class support for it and niceties like plugin types inference etc unless it was trivial to do (ie literally drop-in compatible with the terraform plugins).

However, assuming worst-case scenario, it'd be great to have the following features

  1. Currently easy to replicate with file type overrides and similar:

    • *.pkr.hcl files are treated as *.tf
    • *.pkrvars.hcl files are treated as *.tfvars
    • Packer-specific blocks recognized (ie without necessarily adding in typing, but just to get rid of the unknown block type warning)
  2. (If possible/easy/worth it) Packer support:

    • Vanilla Packer syntax checks on the fields as per Hashicorp's doc
    • Packer plugin types detection and syntax checks

Actual Behavior

A file type override to "Terraform Config" is more or less mandatory for comfortable editing, and generally works surprisingly well.

e.g. see the following (first is as "bare" HCL file, second is as Terraform config):

hcl

terraform

Steps to Reproduce

Write any Packer manifest.