-
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 hooks for dynamic completion #1017
Conversation
a6e0712
to
da74524
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.
LGTM, aside from a few in-line comments, although you may want to look at the upstream hcl-lang
PR first and then rebase here once merged.
"github.com/zclconf/go-cty/cty" | ||
) | ||
|
||
func (h *Hooks) LocalModuleSources(ctx context.Context, value cty.Value) ([]decoder.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.
I'm assuming this would be eventually part of a separate PR? 👀
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 added this as a placeholder to showcase the registration of hooks in AppendCompletionHooks
. Without any hooks we wouldn't be able to create hooks.Hooks{}
.
But I can remove it if you want? And defer everything to the next PR
lsp "github.com/hashicorp/terraform-ls/internal/protocol" | ||
) | ||
|
||
type CompletionItem struct { |
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.
Nitpick: We could move this under the protocol
package as we already have some extensions of the original structs there for telemetry or experimental functions:
https://github.com/hashicorp/terraform-ls/tree/main/internal/protocol
d52944d
to
183acf2
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.
LGTM, aside from that one naming suggestion.
As for the hooks
package and removal of the actual hooks - I'll leave that at your own discretion - as per Slack convo.
internal/protocol/completion.go
Outdated
|
||
import "github.com/hashicorp/hcl-lang/lang" | ||
|
||
type CompletionItemR struct { |
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.
type CompletionItemR struct { | |
type CompletionItemWithResolveHook struct { |
Just for some extra clarity
Making `DecoderContext` public allows us to extend the context after creation.
d67e2c3
to
41f2bbf
Compare
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
This PR introduces a new
hooks
package, which we can use to implement hooks for dynamic completion. Hooks will be implemented as part of hashicorp/vscode-terraform#672.We also introduce a new
completionItem/resolve
handler, which editors can use to update a completion item with more detailed data. The data is obtained via the execution of a resolve hook.