1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

zed-editor: options to generate debug.json

Add `mutableUserDebug` and `userDebug` options to generate `debug.json` file.
The options are heavily inspired by `mutableUserTasks` and `userTasks` options implementation.

Closes #8091
This commit is contained in:
Pierre-Yves Landuré 2025-10-31 12:01:41 +01:00 committed by Austin Horstman
parent 95d65dddae
commit 1f34c2c855
5 changed files with 285 additions and 0 deletions

View file

@ -81,6 +81,15 @@ in
'';
};
mutableUserDebug = mkOption {
type = types.bool;
default = true;
example = false;
description = ''
Whether user debug configurations (debug.json) can be updated by zed.
'';
};
userSettings = mkOption {
type = jsonFormat.type;
default = { };
@ -140,6 +149,27 @@ in
'';
};
userDebug = mkOption {
type = jsonFormat.type;
default = [ ];
example = literalExpression ''
[
{
label = "Go (Delve)";
adapter = "Delve";
program = "$ZED_FILE";
request = "launch";
mode = "debug";
}
]
'';
description = ''
Configuration written to Zed's {file}`debug.json`.
Global debug configurations for Zed's [Debugger](https://zed.dev/docs/debugger).
'';
};
extensions = mkOption {
type = types.listOf types.str;
default = [ ];
@ -241,6 +271,14 @@ in
(jsonFormat.generate "zed-user-tasks" cfg.userTasks)
);
})
(mkIf (cfg.mutableUserDebug && cfg.userDebug != [ ]) {
zedDebugActivation = lib.hm.dag.entryAfter [ "linkGeneration" ] (
impureConfigMerger "[]"
"$dynamic + $static | group_by(.label) | map(reduce .[] as $item ({}; . * $item))"
"${config.xdg.configHome}/zed/debug.json"
(jsonFormat.generate "zed-user-debug" cfg.userDebug)
);
})
];
xdg.configFile = mkMerge [
@ -265,6 +303,9 @@ in
(mkIf (!cfg.mutableUserTasks && cfg.userTasks != [ ]) {
"zed/tasks.json".source = jsonFormat.generate "zed-user-tasks" cfg.userTasks;
})
(mkIf (!cfg.mutableUserDebug && cfg.userDebug != [ ]) {
"zed/debug.json".source = jsonFormat.generate "zed-user-debug" cfg.userDebug;
})
];
assertions = [