fix(opencode): disable auto-format on save

opencode reformats files in the background after each write, which
desyncs the model's view of a file between edits and breaks follow-up
edits whose old_string no longer matches. Set formatter = false; the
formatter tools stay on PATH via home.packages for manual use.
This commit is contained in:
Harald Hoyer 2026-05-21 23:59:58 +02:00
parent a935e77f83
commit 3715e269b9

View file

@ -11,74 +11,13 @@ let
cfg = config.metacfg.cli-apps.opencode; cfg = config.metacfg.cli-apps.opencode;
# Formatters opencode runs on save, each pinned to its exact store path.
formatters = {
nixfmt = {
command = [
(lib.getExe pkgs.nixfmt-rfc-style)
"$FILE"
];
extensions = [ ".nix" ];
};
prettier = {
command = [
(lib.getExe pkgs.nodePackages.prettier)
"--write"
"$FILE"
];
extensions = [
".md"
".yaml"
".yml"
".json"
".css"
".html"
".js"
".ts"
".jsx"
".tsx"
];
};
shfmt = {
command = [
(lib.getExe pkgs.shfmt)
"-w"
"$FILE"
];
extensions = [
".sh"
".bash"
];
};
ruff = {
command = [
(lib.getExe pkgs.ruff)
"format"
"$FILE"
];
extensions = [ ".py" ];
};
taplo = {
command = [
(lib.getExe pkgs.taplo)
"format"
"$FILE"
];
extensions = [ ".toml" ];
};
stylua = {
command = [
(lib.getExe pkgs.stylua)
"$FILE"
];
extensions = [ ".lua" ];
};
};
opencodeConfig = { opencodeConfig = {
"$schema" = "https://opencode.ai/config.json"; "$schema" = "https://opencode.ai/config.json";
lsp = true; lsp = true;
formatter = formatters; # Auto-format on save is disabled: opencode reformats files between the
# model's edits, which desyncs its view and breaks follow-up edits. The
# formatters remain available on PATH (home.packages) for manual use.
formatter = false;
disabled_providers = [ "opencode" ]; disabled_providers = [ "opencode" ];
provider.halo = { provider.halo = {
npm = "@ai-sdk/openai-compatible"; npm = "@ai-sdk/openai-compatible";