hcl-lang icon indicating copy to clipboard operation
hcl-lang copied to clipboard

Add support for upstream `textDocument/rename` lsp support for terraform-ls

Open teddylear opened this issue 2 years ago • 2 comments

A follow up to this issue on terraform-ls, wanted to make this here per @radeksimko suggestion to discuss design of implementing supporting functionality to this repo to be used by terraform-ls to perform renames on resoures/data sources/etc. This would hopefully help support an lsp rename operation on all hcl based configuration. I can start taking a look into this repo to see what functionality would have be added/missing, but very high level plan would be the following:

  • Go to definition of an object
  • Get all references of said object
  • then perform rename operation on all references of object where relevant

If there's anything that should change in this approach or I'm missing please let me know. Also if possible would love to implement this.

teddylear avatar Aug 09 '23 21:08 teddylear

Randomly stumbled across this as well while encountering these limitations myself. Super curious about this as well and open to helping if needed

jchillin avatar Jan 10 '25 18:01 jchillin

@ansgarm Tagging you because I'm not sure of the best person/group to tag for this repo to follow up on issues (if there is a better way please let me know).

Having time to look into this more, I'm assuming for implementation it would be a combination of ReferenceTargetsForOriginAtPos to go to the origin and ReferenceOriginsTargetingPos to get the references of the hcl object. Then combining both of these list should give all positions that need to be renamed by the upstream lsp. These functions may not be used in full pieces may just be copied over to this new rename definition, but I wanted to confirm this approach at a high level makes sense before getting deep into implementation. If there is another approach I should use to accomplish this or if I am way off the mark please let me know.

teddylear avatar Jan 20 '25 19:01 teddylear