From 3715e269b995a3c09c6fc92fc5137df9285b8246 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 21 May 2026 23:59:58 +0200 Subject: [PATCH] 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. --- modules/home/cli-apps/opencode/default.nix | 69 ++-------------------- 1 file changed, 4 insertions(+), 65 deletions(-) diff --git a/modules/home/cli-apps/opencode/default.nix b/modules/home/cli-apps/opencode/default.nix index 6f463e7..fd0ca99 100644 --- a/modules/home/cli-apps/opencode/default.nix +++ b/modules/home/cli-apps/opencode/default.nix @@ -11,74 +11,13 @@ let 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 = { "$schema" = "https://opencode.ai/config.json"; 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" ]; provider.halo = { npm = "@ai-sdk/openai-compatible";