Skip to content

Provide snippet of new for-in and for-in-if in [] or {} #1607

Open
@radeksimko

Description

@radeksimko

Language Server Version

v0.32.6

Problem Statement

Currently one has to hand-type the whole for expression, i.e. no completion is provided inside of [] or {}:
Screenshot 2024-02-05 at 14 02 40

While it is not enormous amount of effort to type it out in terms of character count, there can be many users who simply don't remember the exact syntax, as it is documented at https://developer.hashicorp.com/terraform/language/expressions/for

Attempted Solutions

No response

Proposal

  • Provide completion candidate inside of [ ]
    • for ${1:value} in ${2:collection}: ${3:expr}
    • for ${1:value} in ${2:collection}: ${3:expr} if ${4:condition}
    • for ${1:index}, ${2:value} in ${3:collection}: ${4:expr}
    • for ${1:index}, ${2:value} in ${3:collection}: ${4:expr} if ${5:condition}
  • Provide completion candidate inside of { }
    • for ${1:key}, ${2:value} in ${3:collection}: ${4:keyExpr} => ${5:valueExpr}
    • for ${1:key}, ${2:value} in ${3:collection}: ${4:keyExpr} => ${5:valueExpr} if ${6:condition}

Related LSP methods

No response

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions