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:
parent
7641bab17f
commit
d0c58a5c9d
2 changed files with 37 additions and 0 deletions
|
|
@ -1,6 +1,32 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://opencode.ai/config.json",
|
"$schema": "https://opencode.ai/config.json",
|
||||||
"lsp": true,
|
"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"],
|
"disabled_providers": ["opencode"],
|
||||||
"provider": {
|
"provider": {
|
||||||
"halo": {
|
"halo": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
|
pkgs,
|
||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
@ -29,6 +30,16 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
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" = {
|
xdg.configFile."opencode" = {
|
||||||
source = ../../../../config/opencode;
|
source = ../../../../config/opencode;
|
||||||
recursive = true;
|
recursive = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue