-
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
Support built-in functions #37
Comments
@radeksimko sorry for the noise but is this something I can work on? thanks |
This will involve some upfront work on Terraform Core (to expose functions in some way) and drafting of the design (weighing pros and cons of different approaches), so it's probably not the best issue to pick for someone outside of HashiCorp at this point. It is possible that once the upstream work is finished we could use some extra hands. It is unlikely that there will be progress on this particular issue in the next 3 weeks though. |
Support for functions was implemented as part of the following PRs:
This was all released as part of v0.31.0. There are some related issues to follow-up on which are being tracked separately:
All the features shown in the initial post are however implemented, so I'm going to close this. |
This functionality has been released in v0.31.0 of the language server. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Background
Terraform configuration language has a number of built-in functions, some of which come from HCL.
Proposal - UX/LSP
Name Completion
When a user requests completion on the RHS (after "="), aside from other candidates (such as references), they're presented with function names compatible with the attribute type, i.e. functions which return
string
(or "any type") if the attribute is of typestring
.Argument Completion
When the user confirms the function name from completion or types the opening brace, they are provided with any references of the argument type, i.e. if the argument being completed is of
string
type, then any references ofstring
type are provided.Hover
When the user hovers over the function name, they are provided with the signature of the function, brief description and link to the documentation for that function.
Semantic Tokens
The name of a valid function, such as
format
will be highlighted semantically as function name, name of an invalid function (such asfrmt
) will not. That way users can tell the difference between typo-ed function name and correct one just from the colours.Implementation Notes
zclconf/go-cty
Description
to theSpec
andParameter
types ofzclconf/go-cty/function
stdlib
from docshashicorp/terraform
hashicorp/terraform-schema
Signature
(see below) toterraform-schema
to loosely mimic cty'sfunction.Spec
terraform-schema/internal/funcs/functions.go
using theSignature
type; see prototype for finding return typesFunctionsForVersion(v *version.Version) (map[string]Signature, error)
fromterraform-schema/schema
hashicorp/hcl-lang
Functions map[string]function.Function
to PathContext in hcl-langPathDecoder.CandidatesAtPos
inhcl-lang/decoder
PathDecoder.HoverAtPos
inhcl-lang/decoder
PathDecoder.SemanticTokensInFile
inhcl-lang/decoder
hashicorp/terraform-ls
schema.FunctionsForVersion()
from within the internal/decoder packagetextDocument/signatureHelp
which calls the newPathDecoder.SignatureAtPos()
methodThe text was updated successfully, but these errors were encountered: