-
Notifications
You must be signed in to change notification settings - Fork 24
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
Enable hooks for dynamic completion #123
Conversation
ace4b0c
to
8f7e931
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments in-line, mostly minor though.
Thank you for getting to the bottom of the quoting issue!
All in all it looks pretty good and I guess we can tweak the detection of empty expressions later, when/if necessary, based on some real configs which we find to trigger any bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some really minor suggestions in-line. 👍🏻
} | ||
|
||
func (d *Decoder) SetContext(ctx DecoderContext) { | ||
d.ctx = ctx | ||
} | ||
|
||
type CompletionFunc func(ctx context.Context, value cty.Value) ([]Candidate, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the other PR review
- Add hooks for dynamic completion terraform-ls#1017 (comment)
- Add hooks for dynamic completion terraform-ls#1017 (comment)
is it worth bringing some of the docs here, so we can omit them downstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a valid point, I moved it here.
I'm just wondering how easy the docs are discoverable, one won't be able to see them anywhere on hover in the LS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add a reference or comment to CompletionFuncMap
which is easier to discover downstream on hover.
Co-authored-by: Radek Simko <radek.simko@gmail.com>
This PR extends the completion of attribute values by getting completion candidates from dynamically registered hooks.
If an attribute schema contains one (or multiple) completion hooks, we look in the global decoder context to see if those hooks are registered. If they are, each hook is executed and should return a list of completion candidates.
The resulting candidate always replaces the whole attribute value range (including quotes).