SublimeText / Terraform

Terraform (HCL) configuration file syntax highlighting for Sublime Text
MIT License
164 stars 52 forks source link

colored syntax highlighting breaking at different points #54

Open xork242 opened 2 years ago

xork242 commented 2 years ago

I have a long .tf file where the syntax highlighting is breaking at 2 different points.

In this first snippet, I get an error that no matching bracket is found and the color highlighting changes afterwards, all bracket matching afterwards breaks:

screen1

resource "aws_iam_role_policy" "attach-inline-policy-1" {
    name = "xxx"
    role = aws_iam_role.execution-role.name
    policy = jsonencode({
        Version = "2012-10-17"
        "Statement": [
            {
                "Action": [
                    "lambda:InvokeFunction",
                    "lambda:InvokeAsync"
                ],
                "Resource": "arn:aws:lambda:*:*:function:${var.environment}-xxx",
                "Effect": "Allow"
            }
        ]
    })
}

resource "aws_iam_role_policy" "attach-inline-policy-2" {
    name = "xxx"
    role = aws_iam_role.execution-role.name
    policy = jsonencode({
        Version = "2012-10-17"
        "Statement": [
            {
                "Action": [
                    "sns:Publish"
                ],
                "Resource": [
                    "arn:aws:sns:us-east-1:${var.aws_account_id}:${var.environment}-xxx",
                    "arn:aws:sns:us-east-1:${var.aws_account_id}:${var.environment}-xxx"
                ],
                "Effect": "Allow"
            }
        ]
    })
}

In this second section, all color highlighting completely goes away:

screen2

resource "aws_iam_role_policy" "attach-inline-policy-10" {
    name = "xxx"
    role = aws_iam_role.execution-role.name
    policy = jsonencode({
        Version = "2012-10-17"
        "Statement": [
            {
                "Action": [
                    "s3:Get*",
                    "s3:List*",
                    "s3:PutObject",
                    "ec2:DescribeTags",
                    "logs:*"
                ],
                "Resource": [
                    "arn:aws:s3:::xxx-*",
                    "arn:aws:s3:::xxx-*/*"
                ],
                "Effect": "Allow"
            }
        ]
    })
}

resource "aws_iam_role_policy" "attach-inline-policy-11" {
    name = "xxx"
    role = aws_iam_role.execution-role.name
    policy = jsonencode({
        Version = "2012-10-17"
        "Statement": [
            {
                "Action": [
                    "sns:Publish"
                ],
                "Resource": [
                    "arn:aws:sns:us-east-1:${var.aws_account_id}:${var.environment}_xxx",
                    "arn:aws:sns:us-east-1:${var.aws_account_id}:${var.environment}_xxx"
                ],
                "Effect": "Allow"
            }
        ]
    })
}

Would it be possible to update the plugin to account for this usage? Any other suggestions?

Thanks!

TerminalFi commented 1 year ago

This got me today as well.

larstobi commented 1 year ago

I have switched to a fork of this repo, and with that the code above is correctly highlighted: https://github.com/tmichel/sublime-terraform

FichteFoll commented 3 months ago

For the record, it breaks on the line with "Statement": [.