{"id":15102817,"url":"https://github.com/walteh/retab","last_synced_at":"2025-10-25T14:31:09.059Z","repository":{"id":174430800,"uuid":"652207782","full_name":"walteh/retab","owner":"walteh","description":"custom formatting support for .hcl, .tf, and .proto ➡️","archived":false,"fork":false,"pushed_at":"2025-02-07T12:49:54.000Z","size":35801,"stargazers_count":2,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T13:24:37.635Z","etag":null,"topics":["editorconfig","go","golang","hcl","hcl2","json","jsonschema","tabs","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/walteh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-11T12:40:41.000Z","updated_at":"2025-02-07T12:49:58.000Z","dependencies_parsed_at":"2024-02-29T00:35:37.357Z","dependency_job_id":"95d664ec-770f-43c3-b1a6-53407491300e","html_url":"https://github.com/walteh/retab","commit_stats":null,"previous_names":["nuggxyz/tftab","walteh/tftab","walteh/retab"],"tags_count":218,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walteh%2Fretab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walteh%2Fretab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walteh%2Fretab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walteh%2Fretab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/walteh","download_url":"https://codeload.github.com/walteh/retab/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238161507,"owners_count":19426669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["editorconfig","go","golang","hcl","hcl2","json","jsonschema","tabs","yaml"],"created_at":"2024-09-25T19:07:30.586Z","updated_at":"2025-10-25T14:31:09.049Z","avatar_url":"https://github.com/walteh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# retab\n\nA powerful multi-language code formatter that emphasizes tabs-first formatting, with native support for Protocol Buffers, HCL, and YAML files, plus additional support for external formatters like Terraform, Dart, and Swift.\n\n## Installation\n\n```bash\ngo install github.com/walteh/retab/v2/cmd/retab@latest\n```\n\n## Features\n\n-   **Native Formatters:**\n\n    -   Protocol Buffers (.proto files)\n    -   HashiCorp Configuration Language (HCL)\n    -   YAML (.yaml, .yml files)\n\n-   **External Formatters:**\n\n    -   Terraform (requires `terraform` CLI)\n    -   Dart (requires `dart` CLI)\n    -   Swift (requires `swift-format`)\n\n-   **Tabs-First Approach:** While the formatter respects your `.editorconfig` settings, it's designed with tabs in mind for better accessibility and consistent indentation.\n\n## Usage\n\nFormat a file using the `fmt` command:\n\n```bash\n# Auto-detect formatter based on file extension\nretab fmt myfile.proto\n\n# Explicitly specify formatter\nretab fmt myfile.proto --formatter=proto\nretab fmt myfile.hcl --formatter=hcl\nretab fmt myfile.yaml --formatter=yaml\nretab fmt myfile.tf --formatter=tf\nretab fmt myfile.dart --formatter=dart\nretab fmt myfile.swift --formatter=swift\n```\n\n## Examples\n\n### Protocol Buffers\n\n```protobuf\n// Before formatting\nservice  MyService{rpc   MyMethod(MyRequest)   returns(MyResponse);}\n\n// After formatting (with default tab indentation)\nservice MyService {\n\trpc MyMethod(MyRequest) returns (MyResponse);\n}\n```\n\n### HCL\n\n```hcl\n// Before formatting\nresource \"aws_instance\" \"example\" {ami=\"ami-123456\"\ninstance_type=\"t2.micro\"\n  tags={Name=\"example\"}}\n\n// After formatting (with default tab indentation)\nresource \"aws_instance\" \"example\" {\n\tami           = \"ami-123456\"\n\tinstance_type = \"t2.micro\"\n\ttags = {\n\t\tName = \"example\"\n\t}\n}\n```\n\n### YAML\n\n```yaml\n# Before formatting\nservices:\n  web:\n    image:    nginx:latest\n    ports:  \n     - \"80:80\"\n    volumes:\n      - ./nginx.conf:/etc/nginx/nginx.conf:ro\n    environment:\n          DEBUG: 'true'\n          API_KEY:     'secret'\n\n# After formatting (with default tab indentation)\nservices:\n\tweb:\n\t\timage: nginx:latest\n\t\tports:\n\t\t\t- \"80:80\"\n\t\tvolumes:\n\t\t\t- ./nginx.conf:/etc/nginx/nginx.conf:ro\n\t\tenvironment:\n\t\t\tDEBUG: 'true'\n\t\t\tAPI_KEY: 'secret'\n```\n\n### Swift\n\n```swift\n// Before formatting\nstruct ContentView{\nvar body:some View{\nText(\"Hello, world!\")\n.padding()\n}}\n\n// After formatting (with default indentation)\nstruct ContentView {\n    var body: some View {\n        Text(\"Hello, world!\")\n            .padding()\n    }\n}\n```\n\n## Configuration\n\nretab uses `.editorconfig` for configuration. While designed with tabs in mind, it respects your project's settings. Here's a sample `.editorconfig`:\n\n```ini\n[*]\n# common settings supported\nindent_style = tab   # 'tab' or 'space'\nindent_size = 4     # Size of indentation\nmax_line_length = 120          # Maximum line length for YAML files\n\n# custom settings supported\ntrim_multiple_empty_lines = true  # Remove multiple blank lines\none_bracket_per_line = true  # Force brackets onto new lines\n\n# yaml-specific settings\npad_line_comments = 2        # Padding spaces before line comments\n```\n\nIf no `.editorconfig` is found, it defaults to:\n\n-   Tabs for indentation (recommended)\n-   Tab size of 4\n-   Trim multiple empty lines enabled\n-   One bracket per line enabled\n\n### Swift Formatting Note\n\nWhen using Swift formatting with EditorConfig, indentation settings will only work correctly if your `swift-format` configuration has `spaces=2` set as the indentation (which is the default). If you need different indentation settings, you'll need to modify your `swift-format` configuration file.\n\n### Why Tabs?\n\nWe believe in tabs-first formatting because:\n\n-   Better accessibility for developers using screen readers\n-   Allows each developer to set their preferred indentation width\n-   Smaller file sizes\n-   Clear and unambiguous indentation\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n\nThis project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n-   Adapted from [protocompile](https://github.com/bufbuild/protocompile) for Protocol Buffer formatting\n-   Uses [editorconfig-core-go](https://github.com/editorconfig/editorconfig-core-go) for configuration\n-   Uses [yamlfmt](https://github.com/google/yamlfmt) for YAML formatting","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalteh%2Fretab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalteh%2Fretab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalteh%2Fretab/lists"}