List of HCL reserved keywords

Hi I’m trying to develop a syntax highlighting file for the popular Notepad++ program and would like to request a sample full, complete terraform file with all available keywords including provider specific ones to add to highlighting categories.
Either that or better yet, groups of keywords from top level keywords, to 2nd level keywords, 3rd level, and so on separated in groups by level.

Hi! Have you seen this:

It’s for VS Code, but it’s pretty cool, with autocomplete as well. I want to get something similar working with Sublime Text.

Hi @carlosvsilva,

Unfortunately the design of the Terraform language doesn’t really include a fixed idea of “keyword tokens” like we see in some other languages: the meaning of a particular identifier depends on the context where it appears, so what might seem like a “keyword” in one situation might just be a normal identifier in another situation.

The idea of “all provider-specific keywords” is also not really feasible because providers are a third-party extension point and so new providers can be created by anyone at any time.

I believe existing highlighting definitions for the Terraform language (for other editors) are built using TextMate-style nested regular expression classification, which creates the possibility of contextual matching which unfortunately doesn’t seem to be available for Notepad++ user-defined languages.

It might be best to focus on the punctuation characters that are part of the language grammar, and not try to highlight any identifiers as keywords. You can see all of the symbols currently defined for HCL in Operators and Delimiters in the native syntax specification. Elsewhere in that specification you can also see the different comment forms the language grammar supports.

1 Like