Skip to content

Improve completion within locals #1586

@radeksimko

Description

@radeksimko

Background

The locals block is somewhat unique compared to the rest of the language in that it has cty.DynamicPseudoType constraint, i.e. any type and allows interpolation.

We currently provide very basic completion inside of locals right after the = which brings up all functions and references.

We do not provide completion in many other contexts which may be relevant

  • boolean (true / false)
  • maps (+ inside keys and values)
  • objects (+ inside attribute names and values)
  • tuples (+ elements)
  • lists (+ elements)
  • sets (+ elements)

2024-01-18 09 46 03

Proposal

  • Enable completion for boolean, i.e. true and false
  • Enable completion for new objects, i.e. { ... }
  • Enable completion inside object attribute names, i.e. { (HERE) = "foo" }
  • Enable completion inside object attribute values, i.e. { foo = HERE }
  • Enable completion for new maps, i.e. tomap({ ... })
  • Enable completion inside map keys, i.e. { (HERE) = "foo" }
  • Enable completion inside map values, i.e. { foo = HERE }
  • Enable completion for new tuples, i.e. [ ... ]
  • Enable completion inside tuples, i.e. [ HERE, HERE, ... ]
  • Enable completion for new sets, i.e. toset([ ... ])
  • Enable completion inside sets, i.e. toset([ HERE, HERE, ... ])
  • Enable completion for new lists, i.e. tolist([ ... ])
  • Enable completion inside lists, i.e. tolist([ HERE, HERE, ... ])

Implementation Notes

This can be more broadly described as completion inside of an attribute with the following constraint:

schema.AnyExpression{
  OfType: cty.DynamicPseudoType,
}

i.e. this is relevant for any other language and other parts of the Terraform language which may satisfy the above, not just locals.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions