terramate icon indicating copy to clipboard operation
terramate copied to clipboard

[FEATURE] Allow terramate to format code actively

Open luong-komorebi opened this issue 5 months ago • 0 comments

Is your feature request related to a problem? Please describe. Terramate cli can format codes with terramate fmt. However, this can only happens after the codes have been saved, not during edit, and it has to be explicitly called via the command line interface with the files as arguments.

This is counter-intuitive for a development phase. Since we already have the vscode extension and the language server, we should register the capability to format the code (either the whole file or part of the code) as a capability for language server client to use.

This issue is also logged here https://github.com/terramate-io/vscode-terramate/issues/24 but it does not seem like it is catching attention.

As a developer, I would love to detect early syntax errors and quickly get my code cleanly formatted so that developer exeprience and long term maintenance is better

Describe the solution you'd like

Allow the language server and lsp client to format files Allow vscode users with vscode extension to format .tm.hcl file

Describe alternatives you've considered I am using a precommit hook that is made by terramate themselves.

- repo: https://github.com/mineiros-io/pre-commit-hooks
  rev: v0.5.1
  hooks:
  - id: terramate-fmt
    types:
    - file
    files: \.tm.hcl$

This can be tweaked to support action on file-save or pre commit phases, but it would requires installing pre-commit and get to know a new system outside of the editor with a capable extension

Additional context Add any other context or screenshots about the feature request here.

luong-komorebi avatar Sep 19 '24 12:09 luong-komorebi