Introduce hooks for dynamic completion #868
Labels
enhancement
New feature or request
modules
Functionality related to the module block and modules generally
textDocument/completion
Milestone
Background
We currently provide completion based entirely on schemas, which are sourced either from providers (as JSON), declared within
terraform-schema
, or augmented from the configuration (such as module inputs/outputs based on variables and outputs).Use Cases
There are use cases for a more dynamic completion however
source
andversion
vscode-terraform#672source
&version
vscode-terraform#676which cannot be served using a static nor purely config-informed schema.
Future Related Use Cases
The solution may not necessarily be ready to solve any of these but these look like the same problems that could be solved by the same solution:
provider "aws"
blocksimage
from Docker Hub, Quay and/or other image sources https://www.nomadproject.io/docs/drivers/dockersource_image
from GCP https://www.packer.io/plugins/post-processors/googlecompute/googlecompute-export#basic-exampleProposal
hashicorp/hcl-lang
CompletionHooks []lang.CompletionHook
toschema.AttributeSchema
CompletionHooks CompletionFuncMap
todecoder.DecoderContext
CompletionResolveHooks CompletionResolveFuncMap
todecoder.DecoderContext
Meta interface{}
field todecoder.PathContext
to allow LS to pass extra context (such as which provider/module to pull versions for) to completion hooksMetaFromContext(ctx)
todecoder
to help obtain the metadata from completion hooks in LSCandidatesAtPos()
inPathDecoder
ctx context.Context
argument (for cancellation)AttributeSchema
hcl.Position
via ctx to each hookfilename
via ctx to each hooklang.Path
via ctx to each hookResolveCandidate()
todecoder.PathDecoder
terraform-ls
langserver/handlers
: IntroducecompletionItem/resolve
LSP method which will basically just callPathDecoder.ResolveCandidate()
The text was updated successfully, but these errors were encountered: