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) <noreply@anthropic.com>
This commit is contained in:
Harald Hoyer 2026-05-21 22:02:53 +02:00
parent 7641bab17f
commit d0c58a5c9d
2 changed files with 37 additions and 0 deletions

View file

@ -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": {

View file

@ -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;