-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add support for textDocument/rename
function for terraform resource names and local variables
#1155
Comments
Hi @teddylear The feature makes sense. It is something we are planning to support, although there isn't a particular date yet. If you feel adventurous 😅 you could open an issue in that repo where we can discuss the design details - i.e. what methods would be changed and roughly how, before jumping to the implementation. Otherwise one of us on the internal team will do it at some point. |
@radeksimko thanks for the quick reply! I'll take a stab at implementing, and open a PR once I get a little traction. We can discuss design there if that's alright. Even if this doesn't pan out, fun exercise for me to dig into the codebase. |
@radeksimko Thinking more about this, I'm noticing some issues and weird behavior that I wanted to confirm with the lsp as is. Ideally to do the
variable "test" {
}
output "foo" {
value = var.test
}` Running
|
The thought process behind those ranges was that I'm not entirely against changing the ranges, but would be hesitant to do it merely to enable renaming - in part because we'd make the addressing logic potentially more complex and in part because I'm not sure whether people genuinely expect to land just on the label when the reference refers to the whole block. Also the The only context where we point to the name is local values, mostly because we cannot simultaneously point to the locals {
test = "foo"
}
output "foo" {
value = local.test
} TL;DR I can see how go-to-definition related logic would be appealing to reuse here, but I think we may not be able to leverage it as-is. Also I'm not sure that we want to imply that a block is rename-able just because go-to-definition/go-to-references is enabled on it. These are the reasons we may need to discuss the design. |
@radeksimko Ah makes sense. Thanks again for quick reply. I'll open a ticket on the upstream repo and talk about design. |
Use-cases
Rename terraform resources of different types and it's references much easier. Also rename local variables much safer an easier
Proposal
Allow renaming of local variables and terraform resource names more easily.
Example 1:
Running on name one
bucket
at the end of first line and renamingfoobar
:Example 2:
Run on
bucket_name
on second line and rename tob_name
Related LSP methods
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_rename
Also more than willing to implement this. Just wanted to open issue to make sure this was alright.
The text was updated successfully, but these errors were encountered: