-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: required arguments pre-filled when creating resource #96
Comments
Agreed - this would be a useful feature to have. This could be implemented as part of the completion method via snippets: terraform-ls/internal/terraform/lang/schema.go Lines 11 to 45 in b1c85b9
just hooked from HCL labels, rather than attributes and blocks. With that the required arguments would be pre-filled automatically after picking the type There's just one edge which comes to my mind - what happens if there are already existing attributes within the block? Should we remove all of these and replace them with new ones which are relevant for the new picked type? I think it's important to understand why/when would this happen - it may be because the user made a mistake when picking the type at first and triggered completion again, or it could be because they are migrating away from a deprecated resource name (e.g. So I'm leaning more towards just replacing whatever there may be inside the block with new required arguments, but I'm keen to hear about other use cases where this may not be appropriate. |
replace only if file is saved is probably a good idea, so the user can revert if they dont want that. and if possible, if auto-save is on (i do), only if committed |
my impulse for the least-surprising or least-destructive would be to strictly add the required attributes/blocks without removing the old ones, and count on other validations to notify the user if they end up with unwanted attributes that no longer fit the resource. For example, in the use case where I'm refactoring a resource from old name/attributes to the new, it would be annoying to lose everything, because I might want to reference the known-invalid syntax to copy/refactor an expression, reference, etc. |
@jpogran implemented this as part of the following PRs which will be part of the upcoming LS / extension release:
As mentioned within these issues, the functionality will be (at least initially) opt-in via We also plan to add code action that would provide comparable functionality for existing blocks, which is tracked under hashicorp/vscode-terraform#801 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
It would be awesome to have pre-filled required arguments when created new ressource.
The text was updated successfully, but these errors were encountered: