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;