Skip to content

fmt from stdout should always output the formatted diagram #1577

Done

Description

@jscarrott

I want to use d2 to format on save in helix but as it outputs nothing if the doc is already formatted it can completely delete the diagram if I am not careful.

Activity

  1. alixander commented on Sep 7, 2023

    @alixander
    Collaborator

    oh true

  2. added
    good first issue
    cli
    on May 23, 2024
  3. alixander commented on Oct 5, 2024

    @alixander
    Collaborator
  4. added 2 commits that reference this issue on Dec 11, 2025
    0fa3968
    67608bd
  5. SignalWhisperer commented on Dec 11, 2025

    @SignalWhisperer

    Just to get us started into a discussion around this, I've committed SignalWhisperer@67608bd to explore how this could be done. I'm not a go developer, so please bear with me here.

    One issue I'm noticing is that we don't have contextual arguments, i.e. the arguments are global rather than applicable only to d2 fmt. Trying to align closer to gofmt, I couldn't just reuse -w since that's for --watch currently, which is unrelated to fmt. I went with -W instead for now.

  6. added a commit that references this issue on Feb 4, 2026
    9fa5f0d
  7. oliverpool commented on Feb 4, 2026

    @oliverpool

    I opened a PR with the simplest solution I could find: #2718

    I am using it successfully with helix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clifmtgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions