Cannot configure/disable the rust formatter #4426

Closed
opened 2026-02-16 17:43:45 -05:00 by yindo · 6 comments
Owner

Originally created by @marc2332 on GitHub (Jan 8, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Tweaking or disabling the rust formatter config in opencode.json does not make opencode behave differently in any way, it keeps formatting with the built-in default command.

So for example, even with this config:

{
  "$schema": "https://opencode.ai/config.json",
  "formatter": {
    "rustfmt": {
      "disabled": true,
    }
  }
}

Or:

{
  "$schema": "https://opencode.ai/config.json",
  "formatter": {
    "rustfmt": {
      "command": [
        "rustfmt",
        "+nightly-2025-09-25",
        "--error-on-unformatted",
        "--unstable-features",
        "$FILE"
      ],
      "extensions": [".rs"]
    }
  }
}

It keeps formatting with the default command.

Plugins

None I think? just a baremetal opencode config

OpenCode version

1.1.6 (latest as of now)

Steps to reproduce

  1. Clone https://github.com/marc2332/opencode-broken-rustfmt
  2. Launch opencode
  3. Ask: Change the 'nice' text in main.rs to 'Hello, World'
  4. See that now opencode has not only changed said text but also formatted both main.rs and other_file.rs even though opencode.json is clearly configured to disable rustfmt

Screenshot and/or share link

https://opncd.ai/share/KO2n2DWl

Operating System

Ubuntu 24.04

Terminal

Wezterm

Originally created by @marc2332 on GitHub (Jan 8, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description Tweaking or disabling the rust formatter config in `opencode.json` does not make opencode behave differently in any way, it keeps formatting with the built-in default command. So for example, even with this config: ```json { "$schema": "https://opencode.ai/config.json", "formatter": { "rustfmt": { "disabled": true, } } } ``` Or: ```json { "$schema": "https://opencode.ai/config.json", "formatter": { "rustfmt": { "command": [ "rustfmt", "+nightly-2025-09-25", "--error-on-unformatted", "--unstable-features", "$FILE" ], "extensions": [".rs"] } } } ``` It keeps formatting with the default command. ### Plugins None I think? just a baremetal opencode config ### OpenCode version 1.1.6 (latest as of now) ### Steps to reproduce 1. Clone https://github.com/marc2332/opencode-broken-rustfmt 2. Launch opencode 3. Ask: `Change the 'nice' text in main.rs to 'Hello, World'` 4. See that now opencode has not only changed said text but also formatted both `main.rs` and `other_file.rs` even though `opencode.json` is clearly configured to disable rustfmt ### Screenshot and/or share link https://opncd.ai/share/KO2n2DWl ### Operating System Ubuntu 24.04 ### Terminal Wezterm
yindo added the bug label 2026-02-16 17:43:45 -05:00
yindo closed this issue 2026-02-16 17:43:45 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 8, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #6876: Automatic stylistic changes due to linting errors - reports unwanted formatting changes being applied
  • #4051: Formatters not running after changes - reports formatters not being applied/respected in configurations (closed, appears to be regression)

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 8, 2026): This issue might be a duplicate of existing issues. Please check: - #6876: Automatic stylistic changes due to linting errors - reports unwanted formatting changes being applied - #4051: Formatters not running after changes - reports formatters not being applied/respected in configurations (closed, appears to be regression) Feel free to ignore if none of these address your specific case.
Author
Owner

@cravenceiling commented on GitHub (Jan 8, 2026):

I think it's because of cargo fmt, try this config

{
  "$schema": "https://opencode.ai/config.json",
  "formatter": {
    "rustfmt": {
      "disabled": true,
    },
    "cargo fmt": {
      "disabled": true
    }
  }
}

it worked for me with your repo.

@cravenceiling commented on GitHub (Jan 8, 2026): I think it's because of `cargo fmt`, try this config ```json { "$schema": "https://opencode.ai/config.json", "formatter": { "rustfmt": { "disabled": true, }, "cargo fmt": { "disabled": true } } } ``` it worked for me with your repo.
Author
Owner

@marc2332 commented on GitHub (Jan 8, 2026):

I think it's because of cargo fmt, try this config

{
"$schema": "https://opencode.ai/config.json",
"formatter": {
"rustfmt": {
"disabled": true,
},
"cargo fmt": {
"disabled": true
}
}
}

it worked for me with your repo.

Yep! That fixed the issue for me in the repo and in my project, are the docs in https://opencode.ai/docs/formatters/#built-in then wrong/outdated? I am happy to make a PR then.

This was my intended config btw, just with cargo fmt works.

{
  "$schema": "https://opencode.ai/config.json",
  "formatter": {
    "cargo fmt": {
      "command": [
        "rustfmt",
        "+nightly-2025-09-25",
        "--error-on-unformatted",
        "--unstable-features",
        "$FILE"
      ],
      "extensions": [".rs"]
    }
  }
}
@marc2332 commented on GitHub (Jan 8, 2026): > I think it's because of `cargo fmt`, try this config > > { > "$schema": "https://opencode.ai/config.json", > "formatter": { > "rustfmt": { > "disabled": true, > }, > "cargo fmt": { > "disabled": true > } > } > } > > it worked for me with your repo. Yep! That fixed the issue for me in the repo and in my project, are the docs in https://opencode.ai/docs/formatters/#built-in then wrong/outdated? I am happy to make a PR then. This was my intended config btw, just with `cargo fmt` works. ```json { "$schema": "https://opencode.ai/config.json", "formatter": { "cargo fmt": { "command": [ "rustfmt", "+nightly-2025-09-25", "--error-on-unformatted", "--unstable-features", "$FILE" ], "extensions": [".rs"] } } } ```
Author
Owner

@cravenceiling commented on GitHub (Jan 8, 2026):

I think that's the case, this commit added the cargo fmt support but, as you mention, the docs for this formatter is missing. And of course, I'd say a PR for this is necessary.

@cravenceiling commented on GitHub (Jan 8, 2026): I think that's the case, [this commit](https://github.com/anomalyco/opencode/commit/cdd6ea514b94d8ce71770bb02f33ab979e9ee0f6) added the cargo fmt support but, as you mention, the docs for this formatter is missing. And of course, I'd say a PR for this is necessary.
Author
Owner

@marc2332 commented on GitHub (Jan 8, 2026):

I think that's the case, this commit added the cargo fmt support but, as you mention, the docs for this formatter is missing. And of course, I'd say a PR for this is necessary.

Done! https://github.com/anomalyco/opencode/pull/7383

@marc2332 commented on GitHub (Jan 8, 2026): > I think that's the case, [this commit](https://github.com/anomalyco/opencode/commit/cdd6ea514b94d8ce71770bb02f33ab979e9ee0f6) added the cargo fmt support but, as you mention, the docs for this formatter is missing. And of course, I'd say a PR for this is necessary. Done! https://github.com/anomalyco/opencode/pull/7383
Author
Owner

@rekram1-node commented on GitHub (Jan 8, 2026):

To those seeing this, note that when this is released the key will be "cargofmt" not "cargo fmt", this is inline with our other configs and I should've caught it in original pr.

Ik this could "break" some configs but given docs were wrong I think it is okay

@rekram1-node commented on GitHub (Jan 8, 2026): To those seeing this, note that when this is released the key will be "cargofmt" not "cargo fmt", this is inline with our other configs and I should've caught it in original pr. Ik this could "break" some configs but given docs were wrong I think it is okay
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4426