Skip to content

Add basic indentation rules #82

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

Merged
merged 1 commit into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Indentation Rules.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>scope</key>
<string>source.hcl, source.terraform, source.terraform-vars</string>
<key>settings</key>
<dict>
<key>decreaseIndentPattern</key>
<string>^\s*[])}]</string>
<key>increaseIndentPattern</key>
<string><![CDATA[(?x)
^.* # anything on the line followed by:
(
\[[^]"']* # an open square bracket not followed by a closing square bracket or string punctuation
| \([^)"']* # an open bracket not followed by a closing bracket or string punctuation
| \{[^}"']* # an open curly brace not followed by a closing brace or string punctuation
)$
]]></string>
<key>indentParens</key>
<false/>
<key>indentSquareBrackets</key>
<false/>
</dict>
</dict>
</plist>
38 changes: 38 additions & 0 deletions tests/syntax_test_reindent.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SYNTAX TEST reindent-unchanged "Terraform.sublime-syntax"

provider "name" {
attr1 = {
key1 = {
key11 = {
key111 = 0
key112 = [
"0",
"1"
]
},
key12 = [
0,
1,
],
key13 = (
var.member
+ var.other
)
}
}

attr2 = jsondecode(
{
"key1": {
"key11": [
0,
1
],
"key12": {
"key121": "value",
"key122": 0
}
}
}
)
}