-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for HCL ([HashiCorp configuration language](https://github.com/hashicorp/hcl)).
- Loading branch information
1 parent
4f6f3c7
commit c939df8
Showing
13 changed files
with
459 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
Prism.languages.hcl = { | ||
'comment': /(?:\/\/|#).*|\/\*[\s\S]*?(?:\*\/|$)/, | ||
'heredoc': { | ||
pattern: /<<-?(\w+)[\s\S]*?^\s*\1/m, | ||
greedy: true, | ||
alias: 'string' | ||
}, | ||
'keyword': [ | ||
{ | ||
pattern: /(?:resource|data)\s+(?:"(?:\\[\s\S]|[^\\"])*")(?=\s+"[\w-]+"\s+{)/i, | ||
inside: { | ||
'type': { | ||
pattern: /(resource|data|\s+)(?:"(?:\\[\s\S]|[^\\"])*")/i, | ||
lookbehind: true, | ||
alias: 'variable' | ||
} | ||
} | ||
}, | ||
{ | ||
pattern: /(?:provider|provisioner|variable|output|module|backend)\s+(?:[\w-]+|"(?:\\[\s\S]|[^\\"])*")\s+(?={)/i, | ||
inside: { | ||
'type': { | ||
pattern: /(provider|provisioner|variable|output|module|backend)\s+(?:[\w-]+|"(?:\\[\s\S]|[^\\"])*")\s+/i, | ||
lookbehind: true, | ||
alias: 'variable' | ||
} | ||
} | ||
}, | ||
{ | ||
pattern: /[\w-]+(?=\s+{)/ | ||
} | ||
], | ||
'property': [ | ||
/[\w-\.]+(?=\s*=(?!=))/, | ||
/"(?:\\[\s\S]|[^\\"])+"(?=\s*[:=])/, | ||
], | ||
'string': { | ||
pattern: /"(?:[^\\$"]|\\[\s\S]|\$(?:(?=")|\$+|[^"${])|\$\{(?:[^{}"]|"(?:[^\\"]|\\[\s\S])*")*\})*"/, | ||
greedy: true, | ||
inside: { | ||
'interpolation': { | ||
pattern: /(^|[^$])\$\{(?:[^{}"]|"(?:[^\\"]|\\[\s\S])*")*\}/, | ||
lookbehind: true, | ||
inside: { | ||
'type': { | ||
pattern: /(\b(?:terraform|var|self|count|module|path|data|local)\b\.)[\w\*]+/i, | ||
lookbehind: true, | ||
alias: 'variable' | ||
}, | ||
'keyword': /\b(?:terraform|var|self|count|module|path|data|local)\b/i, | ||
'function': /\w+(?=\()/, | ||
'string': { | ||
pattern: /"(?:\\[\s\S]|[^\\"])*"/, | ||
greedy: true, | ||
}, | ||
'number': /\b0x[\da-f]+|\d+\.?\d*(?:e[+-]?\d+)?/i, | ||
'punctuation': /[!\$#%&'()*+,.\/;<=>@\[\\\]^`{|}~?:]/, | ||
} | ||
}, | ||
} | ||
}, | ||
'number': /\b0x[\da-f]+|\d+\.?\d*(?:e[+-]?\d+)?/i, | ||
'boolean': /\b(?:true|false)\b/i, | ||
'punctuation': /[=\[\]{}]/, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<h2>Comments</h2> | ||
<pre><code># Configure the AWS Provider | ||
// Configure the AWS Provider | ||
</code></pre> | ||
|
||
<h2>Resources</h2> | ||
<pre><code>resource "aws_instance" "web" { | ||
ami = "${data.aws_ami.ubuntu.id}" | ||
instance_type = "t2.micro" | ||
|
||
tags { | ||
Name = "HelloWorld" | ||
} | ||
}</code></pre> | ||
|
||
<h2>Provider</h2> | ||
<pre><code>provider "aws" { | ||
access_key = "${var.aws_access_key}" | ||
secret_key = "${var.aws_secret_key}" | ||
region = "us-east-1" | ||
}</code></pre> | ||
|
||
<h2>Variables</h2> | ||
<pre><code>variable "images" { | ||
type = "map" | ||
|
||
default = { | ||
us-east-1 = "image-1234" | ||
us-west-2 = "image-4567" | ||
} | ||
}</code></pre> | ||
|
||
<h2>Outputs</h2> | ||
<pre><code>output "address" { | ||
value = "${aws_instance.db.public_dns}" | ||
}</code></pre> | ||
|
||
<h2>Modules</h2> | ||
<pre><code>module "consul" { | ||
source = "hashicorp/consul/aws" | ||
servers = 5 | ||
}</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# foo bar | ||
// foo bar | ||
/* | ||
* multi line | ||
*/ | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "# foo bar"], | ||
["comment", "// foo bar"], | ||
["comment", "/*\r\n * multi line\r\n */"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
"${data.aws_availability_zones.available.names[0]}" | ||
"${aws_db_subnet_group.default.id}" | ||
"${var.something ? 1 : 0}" | ||
"${var.num ? 1.02 : 0}" | ||
"${length(var.hostnames)}" | ||
"${format("web-%03d", count.index + 1)}" | ||
"${file("templates/web_init.tpl")}" | ||
"${replace(var.sub_domain, ".", "\\\\\\\\.")}" | ||
"${filepath.foo}" | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", | ||
[ | ||
"\"", | ||
[ | ||
"interpolation", | ||
[ | ||
["punctuation", "$"], | ||
["punctuation", "{"], | ||
["keyword", "data"], | ||
["punctuation", "."], | ||
["type", "aws_availability_zones"], | ||
["punctuation", "."], | ||
"available", | ||
["punctuation", "."], | ||
"names", | ||
["punctuation", "["], | ||
["number", "0"], | ||
["punctuation", "]"], | ||
["punctuation", "}"] | ||
] | ||
], | ||
"\"" | ||
] | ||
], | ||
["string", | ||
[ | ||
"\"", | ||
[ | ||
"interpolation", | ||
[ | ||
["punctuation", "$"], | ||
["punctuation", "{"], | ||
"aws_db_subnet_group", | ||
["punctuation", "."], | ||
"default", | ||
["punctuation", "."], | ||
"id", | ||
["punctuation", "}"] | ||
] | ||
], | ||
"\"" | ||
] | ||
], | ||
["string", | ||
[ | ||
"\"", | ||
[ | ||
"interpolation", | ||
[ | ||
["punctuation", "$"], | ||
["punctuation", "{"], | ||
["keyword", "var"], | ||
["punctuation", "."], | ||
["type", "something"], | ||
["punctuation", "?"], | ||
["number", "1"], | ||
["punctuation", ":"], | ||
["number", "0"], | ||
["punctuation", "}"] | ||
] | ||
], | ||
"\"" | ||
] | ||
], | ||
["string", | ||
[ | ||
"\"", | ||
[ | ||
"interpolation", | ||
[ | ||
["punctuation", "$"], | ||
["punctuation", "{"], | ||
["keyword", "var"], | ||
["punctuation", "."], | ||
["type", "num"], | ||
["punctuation", "?"], | ||
["number", "1.02"], | ||
["punctuation", ":"], | ||
["number", "0"], | ||
["punctuation", "}"] | ||
] | ||
], | ||
"\"" | ||
] | ||
], | ||
["string", | ||
[ | ||
"\"", | ||
[ | ||
"interpolation", | ||
[ | ||
["punctuation", "$"], | ||
["punctuation", "{"], | ||
["function", "length"], | ||
["punctuation", "("], | ||
["keyword", "var"], | ||
["punctuation", "."], | ||
["type", "hostnames"], | ||
["punctuation", ")"], | ||
["punctuation", "}"] | ||
] | ||
], | ||
"\"" | ||
] | ||
], | ||
["string", | ||
[ | ||
"\"", | ||
[ | ||
"interpolation", | ||
[ | ||
["punctuation", "$"], | ||
["punctuation", "{"], | ||
["function", "format"], | ||
["punctuation", "("], | ||
["string", "\"web-%03d\""], | ||
["punctuation", ","], | ||
["keyword", "count"], | ||
["punctuation", "."], | ||
["type", "index"], | ||
["punctuation", "+"], | ||
["number", "1"], | ||
["punctuation", ")"], | ||
["punctuation", "}"] | ||
] | ||
], | ||
"\"" | ||
] | ||
], | ||
["string", | ||
[ | ||
"\"", | ||
[ | ||
"interpolation", | ||
[ | ||
["punctuation", "$"], | ||
["punctuation", "{"], | ||
["function", "file"], | ||
["punctuation", "("], | ||
["string", "\"templates/web_init.tpl\""], | ||
["punctuation", ")"], | ||
["punctuation", "}"] | ||
] | ||
], | ||
"\"" | ||
] | ||
], | ||
["string", | ||
[ | ||
"\"", | ||
[ | ||
"interpolation", | ||
[ | ||
["punctuation", "$"], | ||
["punctuation", "{"], | ||
["function", "replace"], | ||
["punctuation", "("], | ||
["keyword", "var"], | ||
["punctuation", "."], | ||
["type", "sub_domain"], | ||
["punctuation", ","], | ||
["string", "\".\""], | ||
["punctuation", ","], | ||
["string", "\"\\\\\\\\\\\\\\\\.\""], | ||
["punctuation", ")"], | ||
["punctuation", "}"] | ||
] | ||
], | ||
"\"" | ||
] | ||
], | ||
["string", | ||
[ | ||
"\"", | ||
[ | ||
"interpolation", | ||
[ | ||
["punctuation", "$"], | ||
["punctuation", "{"], | ||
"filepath", | ||
["punctuation", "."], | ||
"foo", | ||
["punctuation", "}"] | ||
] | ||
], | ||
"\"" | ||
] | ||
] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all interpolation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
resource "aws_db_instance" "main" { | ||
data "terraform_remote_state" "main" { | ||
output "dev_vpc_id" { | ||
config { | ||
terraform { | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", | ||
["resource ", | ||
["type", "\"aws_db_instance\""]]], | ||
["string", ["\"main\""]], | ||
["punctuation", "{"], | ||
["keyword", | ||
["data ", | ||
["type", "\"terraform_remote_state\""]]], | ||
["string", ["\"main\""]], | ||
["punctuation", "{"], | ||
["keyword", | ||
["output", | ||
["type", " \"dev_vpc_id\" "]]], | ||
["punctuation", "{"], | ||
["keyword", "config"], | ||
["punctuation", "{"], | ||
["keyword", "terraform"], | ||
["punctuation", "{"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all keywords. |
Oops, something went wrong.