From d0c58a5c9dbce61da21e48d76392da432083de18 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 21 May 2026 22:02:53 +0200 Subject: [PATCH] feat(opencode): configure formatters and provide them on PATH Add formatter entries for nix, prettier (md/yaml/json/web), shell, python, toml and lua, and install the matching tools via the opencode home module so they are available wherever opencode runs. Co-Authored-By: Claude Opus 4.7 (1M context) --- config/opencode/config.json | 26 ++++++++++++++++++++++ modules/home/cli-apps/opencode/default.nix | 11 +++++++++ 2 files changed, 37 insertions(+) diff --git a/config/opencode/config.json b/config/opencode/config.json index c854526..dad56b3 100644 --- a/config/opencode/config.json +++ b/config/opencode/config.json @@ -1,6 +1,32 @@ { "$schema": "https://opencode.ai/config.json", "lsp": true, + "formatter": { + "nixfmt": { + "command": ["nixfmt", "$FILE"], + "extensions": [".nix"] + }, + "prettier": { + "command": ["prettier", "--write", "$FILE"], + "extensions": [".md", ".yaml", ".yml", ".json", ".css", ".html", ".js", ".ts", ".jsx", ".tsx"] + }, + "shfmt": { + "command": ["shfmt", "-w", "$FILE"], + "extensions": [".sh", ".bash"] + }, + "ruff": { + "command": ["ruff", "format", "$FILE"], + "extensions": [".py"] + }, + "taplo": { + "command": ["taplo", "format", "$FILE"], + "extensions": [".toml"] + }, + "stylua": { + "command": ["stylua", "$FILE"], + "extensions": [".lua"] + } + }, "disabled_providers": ["opencode"], "provider": { "halo": { diff --git a/modules/home/cli-apps/opencode/default.nix b/modules/home/cli-apps/opencode/default.nix index f1ca10b..f2b54c7 100644 --- a/modules/home/cli-apps/opencode/default.nix +++ b/modules/home/cli-apps/opencode/default.nix @@ -1,6 +1,7 @@ { lib, config, + pkgs, inputs, ... }: @@ -29,6 +30,16 @@ in }; config = mkIf cfg.enable { + # Formatters referenced by config/opencode/config.json; keep them on PATH for opencode. + home.packages = [ + pkgs.nixfmt-rfc-style + pkgs.nodePackages.prettier + pkgs.shfmt + pkgs.ruff + pkgs.taplo + pkgs.stylua + ]; + xdg.configFile."opencode" = { source = ../../../../config/opencode; recursive = true;