syntax icon indicating copy to clipboard operation
syntax copied to clipboard

Improve highlighting of built-in functions

Open dbanck opened this issue 3 years ago • 1 comments

The current version of the Terraform language grammar contains a list of built-in functions. However, as we don't know which version of Terraform a user uses, it is highly possible that the list is either incomplete or contains removed functions.

https://github.com/hashicorp/vscode-terraform/blob/562c7cd7b27b5599b4fb1d4ae21b4fc63639dd91/syntaxes/terraform.tmGrammar.json#L750

To improve the syntax highlighting of built-in functions, we should remove the static list from the grammar file and use semantic token highlighting via the LS. The language server has a better understanding of which Terraform version is used and which functions are available in this version.

dbanck avatar Feb 04 '22 11:02 dbanck

Just wanted to add (as @jpogran proposed) that in addition to semantic token highlighting in LS we could also consider generating the grammar from a list of functions which would provide convenient way of highlighting correct function names.

This means however that we'd need to - (1) have the list of functions accessible somewhere (see https://github.com/hashicorp/terraform-ls/issues/37 and/or TF-418), and (2) always reflect only the latest version of Terraform language in the grammar.

We could do something similar for variable types - with the same caveats as above.

That is not to propose this needs to be addressed together but just to add some context for posterity.

radeksimko avatar Feb 04 '22 12:02 radeksimko