mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-31 04:04:32 +00:00
Merge 5738fa02ec
into 693840c01b
This commit is contained in:
commit
a47d5c792b
5 changed files with 121 additions and 18 deletions
|
@ -1,22 +1,25 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.programs.zed-editor;
|
cfg = config.programs.zed-editor;
|
||||||
jsonFormat = pkgs.formats.json { };
|
jsonFormat = pkgs.formats.json { };
|
||||||
|
|
||||||
mergedSettings = cfg.userSettings
|
mergedSettings = cfg.userSettings
|
||||||
// (lib.optionalAttrs (builtins.length cfg.extensions > 0) {
|
// (lib.optionalAttrs (builtins.length cfg.extensions > 0) {
|
||||||
# this part by @cmacrae
|
# by @cmacrae
|
||||||
auto_install_extensions = lib.genAttrs cfg.extensions (_: true);
|
auto_install_extensions = lib.genAttrs cfg.extensions (_: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
buildThemes = themes:
|
||||||
|
lib.listToAttrs (map (theme: {
|
||||||
|
name = "zed/themes/${theme.name}.json";
|
||||||
|
value = { source = jsonFormat.generate "zed-theme-${theme.name}" theme; };
|
||||||
|
}) themes);
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ hm.maintainers.libewa ];
|
meta.maintainers = [ hm.maintainers.libewa ];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
# TODO: add vscode option parity (installing extensions, configuring
|
# TODO: add vscode option parity (installing extensions, configuring, keybinds with nix etc.)
|
||||||
# keybinds with nix etc.)
|
|
||||||
programs.zed-editor = {
|
programs.zed-editor = {
|
||||||
enable = mkEnableOption
|
enable = mkEnableOption
|
||||||
"Zed, the high performance, multiplayer code editor from the creators of Atom and Tree-sitter";
|
"Zed, the high performance, multiplayer code editor from the creators of Atom and Tree-sitter";
|
||||||
|
@ -61,7 +64,7 @@ in {
|
||||||
bindings = {
|
bindings = {
|
||||||
ctrl-shift-t = "workspace::NewTerminal";
|
ctrl-shift-t = "workspace::NewTerminal";
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
]
|
]
|
||||||
'';
|
'';
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -69,6 +72,32 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
userThemes = mkOption {
|
||||||
|
type = types.listOf jsonFormat.type;
|
||||||
|
default = [ ];
|
||||||
|
example = literalExpression ''
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name = "example 1";
|
||||||
|
author = "user";
|
||||||
|
themes = [
|
||||||
|
{
|
||||||
|
name = "example 1";
|
||||||
|
appearance = "dark";
|
||||||
|
style = {
|
||||||
|
background = "#000000";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
Local themes written to {file}`$XDG_CONFIG_HOME/zed/themes`.
|
||||||
|
See <https://zed.dev/docs/extensions/themes> for more information.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
extensions = mkOption {
|
extensions = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
|
@ -122,15 +151,19 @@ in {
|
||||||
binaryName = "zed-remote-server-stable-${version}";
|
binaryName = "zed-remote-server-stable-${version}";
|
||||||
in {
|
in {
|
||||||
".zed_server/${binaryName}".source =
|
".zed_server/${binaryName}".source =
|
||||||
lib.getExe' remote_server binaryName;
|
lib.getExe' remote_server binaryName;
|
||||||
});
|
});
|
||||||
|
|
||||||
xdg.configFile."zed/settings.json" = (mkIf (mergedSettings != { }) {
|
xdg.configFile = mkMerge [
|
||||||
source = jsonFormat.generate "zed-user-settings" mergedSettings;
|
{
|
||||||
});
|
"zed/settings.json" = mkIf (mergedSettings != { }) {
|
||||||
|
source = jsonFormat.generate "zed-user-settings" mergedSettings;
|
||||||
xdg.configFile."zed/keymap.json" = (mkIf (cfg.userKeymaps != { }) {
|
};
|
||||||
source = jsonFormat.generate "zed-user-keymaps" cfg.userKeymaps;
|
"zed/keymap.json" = mkIf (cfg.userKeymaps != { }) {
|
||||||
});
|
source = jsonFormat.generate "zed-user-keymaps" cfg.userKeymaps;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(lib.mkIf (cfg.userThemes != [ ]) (buildThemes cfg.userThemes))
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
0
tests/flake.lock
generated
Normal file
0
tests/flake.lock
generated
Normal file
|
@ -3,4 +3,5 @@
|
||||||
zed-install-remote-server = ./install-remote-server.nix;
|
zed-install-remote-server = ./install-remote-server.nix;
|
||||||
zed-keymap = ./keymap.nix;
|
zed-keymap = ./keymap.nix;
|
||||||
zed-settings = ./settings.nix;
|
zed-settings = ./settings.nix;
|
||||||
|
zed-themes = ./themes.nix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# Test custom keymap functionality
|
# Test custom settings functionality
|
||||||
{ config, ... }:
|
{ config, ... }: {
|
||||||
|
|
||||||
{
|
|
||||||
programs.zed-editor = {
|
programs.zed-editor = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = config.lib.test.mkStubPackage { };
|
package = config.lib.test.mkStubPackage { };
|
||||||
|
|
71
tests/modules/programs/zed-editor/themes.nix
Normal file
71
tests/modules/programs/zed-editor/themes.nix
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
# Test custom theme functionality
|
||||||
|
{ config, ... }: {
|
||||||
|
programs.zed-editor = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage { };
|
||||||
|
userThemes = [{
|
||||||
|
name = "Test";
|
||||||
|
author = "user";
|
||||||
|
themes = [{
|
||||||
|
name = "Test Catppuccin";
|
||||||
|
appearance = "light";
|
||||||
|
style = {
|
||||||
|
editor = {
|
||||||
|
foreground = "#4c4f69";
|
||||||
|
background = "#eff1f5";
|
||||||
|
gutter.background = "#eff1f5";
|
||||||
|
subheader.background = "#e6e9ef";
|
||||||
|
active_line.background = "#4c4f690d";
|
||||||
|
highlighted_line.background = null;
|
||||||
|
line_number = "#8c8fa1";
|
||||||
|
active_line_number = "#8839ef";
|
||||||
|
invisible = "#7c7f9366";
|
||||||
|
wrap_guide = "#acb0be";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}];
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = let
|
||||||
|
expectedContent = builtins.toFile "expected.json" ''
|
||||||
|
{
|
||||||
|
"author": "user",
|
||||||
|
"name": "test",
|
||||||
|
"themes": [
|
||||||
|
{
|
||||||
|
"appearance": "light",
|
||||||
|
"name": "Test Catppuccin",
|
||||||
|
"style": {
|
||||||
|
"editor": {
|
||||||
|
"active_line": {
|
||||||
|
"background": "#4c4f690d"
|
||||||
|
},
|
||||||
|
"active_line_number": "#8839ef",
|
||||||
|
"background": "#eff1f5",
|
||||||
|
"foreground": "#4c4f69",
|
||||||
|
"gutter": {
|
||||||
|
"background": "#eff1f5"
|
||||||
|
},
|
||||||
|
"highlighted_line": {
|
||||||
|
"background": null
|
||||||
|
},
|
||||||
|
"invisible": "#7c7f9366",
|
||||||
|
"line_number": "#8c8fa1",
|
||||||
|
"subheader": {
|
||||||
|
"background": "#e6e9ef"
|
||||||
|
},
|
||||||
|
"wrap_guide": "#acb0be"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
testPath = ".config/zed/themes/test.json";
|
||||||
|
in ''
|
||||||
|
assertFileExists "home-files/${testPath}"
|
||||||
|
assertFileContent "home-files/${testPath}" "${expectedContent}"
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue