[FEATURE]: Restrict formatting only to the edited range for clang-format (and Prettier)
Range-Based Code Formatting Enhancement
Overview
Implemented intelligent range-based formatting that only formats edited code sections, preventing unrelated formatting changes from cluttering diffs when using the Edit tool.
@micuintus you can do this already:
{
"$schema": "https://opencode.ai/config.json",
"formatter": false,
}
@rekram1-node But that means formatting is disabled globally? I cannot tell my LLM in the same session to skip formatting as I could with 6e2d694?
I guess I see what u mean, kinda hesitant to be adding things to edit tool tho
@rekram1-node
I guess I see what u mean, kinda hesitant to be adding things to edit tool tho
Gotcha!
I went back to the drawing board and realised: What I actually want is not to discard the formatting, but restrict the auto-formatting to only the sections of the file that were changed.
- I updated this issue's description and the PR https://github.com/sst/opencode/pull/4604
- Seems be working like a charm (no pun intended :P)
- For me it resolves a VERY annoying issue, which rendered OpenCode unusable in these use cases (1000 of formatting changes)
@micuintus you can do this already:
{ "$schema": "https://opencode.ai/config.json", "formatter": false, }
I've tried this, and I get:
opencode --continue 1293ms Thu 27 Nov 18:11:59 2025
↳ Invalid input: expected record, received boolean formatter
Are you sure this is right? I want to disable this as it's a really annoying thing to have on by default and makes any PR to a codebase that might have its own custom rules spammed with irrelevant formatting changes.
I've tried manually disabling uv and ruff by using the custom entries as defined here but, my Python code still is littered with random newlines in places not even adjusted.
Is there a way to disable this globally? I don't want my coding agent editor to reformat anything
@micuintus you can do this already: I've tried manually disabling
uvandruffby using the custom entries as defined here but, my Python code still is littered with random newlines in places not even adjusted. Is there a way to disable this globally? I don't want my coding agent editor to reformat anything
Have you tried out my branch? When making changes with opencode it has to make some changes to the code -- that is the whole idea after all :). As LLMs have the tendency to make weirdly formatted code (trailing whitespaces, wrong indentation) it makes sense to autoformat these changes -- they have to be formatted somehow.
@rekram1-node bump :)
@jamesforwardnwboxed you must be on an older version of opencode?
@micuintus yeah sorry for delays super busy rn