Code Monkey home page Code Monkey logo

Comments (7)

pgporada avatar pgporada commented on June 12, 2024

Hrmm, that is frustrating. I haven't played with the ternary operators yet and will need to investigate.

from vim-terraform.

tee33 avatar tee33 commented on June 12, 2024

i ran into this problem today with let g:terraform_align=1 set.

from vim-terraform.

lae avatar lae commented on June 12, 2024

I was wondering, but is this still reproducible? It seems to work fine with the example in OP, as used below:

resource "test" "hi" {
  param = "${var.envtype == "prod" ? "" : var.envtype}"
}

I also tried adding random whitespace in the example and it reformatted to the above example.

]$  terraform --version
Terraform v0.12.4
$  vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul  4 2019 23:02:48)

from vim-terraform.

lae avatar lae commented on June 12, 2024

I'm thinking this was fixed in terraform >=0.12 and not a bug in this plugin itself. hashicorp/terraform#18458 (comment)

from vim-terraform.

dimbleby avatar dimbleby commented on June 12, 2024

This issue is nothing to do with the terraform binary - it's about formatting that the plugin does as you type, before terraform fmt gets near to it.

from vim-terraform.

pgporada avatar pgporada commented on June 12, 2024

I think I found a solution to this problem thanks to https://stackoverflow.com/a/23840400.

If I create file.tf with the contents

resource "test" "hi" {
  param = "${var.envtype == "prod" ? "" : var.envtype}"
}

and then alter the file to have these contents

resource "test" "hi" {
  param = "${var.envtype == "prod" ? "" : var.envtype}"
  test = "${var.envtype == "prod" ? "" : var.envtype}"
}

By the time I enter a newline, the alignment is fixed and only the first = is aligned

resource "test" "test1" {
  param = "${var.envtype == "prod" ? "" : var.envtype}"
  test  = "${var.envtype == "staging" ? "" : var.envtype}"
}

rather than producing the broken string like the current implementation does

resource "test" "hi" {
  param = "${var.envtype = = "prod" ? "" : var.envtype}"
}

from vim-terraform.

mmalchuk avatar mmalchuk commented on June 12, 2024

PR #105 will fix the issue. it safe to mergу it to the master. thanks.

from vim-terraform.

Related Issues (20)

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.