Skip to content

Conversation

trufae
Copy link

@trufae trufae commented Oct 8, 2025

My Report

My project have a .clang-format file in the home directory, opencode will ALWAYS run clang-format if that file exists. using custom configurations like disableing formatters is totally ignored, so i had to apply this fix to tell it not to ignore me.

Grok Explanation of the bug and the fix

The bug was that the formatters object was keyed by the export names from the Formatter module (e.g., 'clang'), but the configuration uses the name property of each formatter (e.g., "clang-format"). This mismatch meant that disabling a formatter in the config, like setting "clang-format": { "disabled": true }, wouldn't actually remove it because delete formatters["clang-format"] was trying to delete a key that didn't exist.

I fixed this by rebuilding the formatters object to use the name property as keys instead of the export names. Now the keys match what the config expects, so disabling formatters works correctly.

@rekram1-node
Copy link
Collaborator

rekram1-node commented Oct 8, 2025

@trufae it gets respected if you ignore like so:

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

@trufae
Copy link
Author

trufae commented Oct 8, 2025

Ouch! i was trying clang-format instead of "clang". that worked

@trufae trufae closed this Oct 8, 2025
@rekram1-node
Copy link
Collaborator

rekram1-node commented Oct 9, 2025

@trufae as you noticed tho we should probably change the name or the docs to be consistent, I think if we merge this pr it would actually make more sense potentially just need to double check all the other formatters will remain as expected but i think:
https://opencode.ai/docs/formatters/#built-in

doing this makes more sense given docs

right?

@rekram1-node rekram1-node reopened this Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants