mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 03:29:45 +01:00
zed-editor: add module
Add a simple module for zed-editor, a simple editor written in Rust.
This commit is contained in:
parent
9c1a1c7df4
commit
e78cbb2027
9 changed files with 210 additions and 0 deletions
|
@ -349,6 +349,11 @@
|
|||
githubId = 12465195;
|
||||
name = "Bruno BELANYI";
|
||||
};
|
||||
libewa = {
|
||||
email = "libewa-git@icloud.com";
|
||||
github = "libewa";
|
||||
githubId = 67926131;
|
||||
};
|
||||
malvo = {
|
||||
email = "malte@malvo.org";
|
||||
github = "malte-v";
|
||||
|
|
|
@ -1770,6 +1770,16 @@ in {
|
|||
ideas from mutt.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2024-10-17T13:07:55+00:00";
|
||||
message = ''
|
||||
A new module is available: 'programs.zed-editor'.
|
||||
|
||||
Zed is a fast text editor for macOS and Linux.
|
||||
See https://zed.dev for more.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -262,6 +262,7 @@ let
|
|||
./programs/yt-dlp.nix
|
||||
./programs/z-lua.nix
|
||||
./programs/zathura.nix
|
||||
./programs/zed-editor.nix
|
||||
./programs/zellij.nix
|
||||
./programs/zk.nix
|
||||
./programs/zoxide.nix
|
||||
|
|
89
modules/programs/zed-editor.nix
Normal file
89
modules/programs/zed-editor.nix
Normal file
|
@ -0,0 +1,89 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.programs.zed-editor;
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
|
||||
mergedSettings = cfg.userSettings // {
|
||||
# this part by @cmacrae
|
||||
auto_install_extensions = lib.genAttrs cfg.extensions (_: true);
|
||||
};
|
||||
in {
|
||||
meta.maintainers = [ hm.maintainers.libewa ];
|
||||
|
||||
options = {
|
||||
# TODO: add vscode option parity (installing extensions, configuring
|
||||
# keybinds with nix etc.)
|
||||
programs.zed-editor = {
|
||||
enable = mkEnableOption
|
||||
"Zed, the high performance, multiplayer code editor from the creators of Atom and Tree-sitter";
|
||||
|
||||
package = mkPackageOption pkgs "zed-editor" { };
|
||||
|
||||
userSettings = mkOption {
|
||||
type = jsonFormat.type;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
{
|
||||
features = {
|
||||
copilot = false;
|
||||
};
|
||||
telemetry = {
|
||||
metrics = false;
|
||||
};
|
||||
vim_mode = false;
|
||||
ui_font_size = 16;
|
||||
buffer_font_size = 16;
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to Zed's {file}`settings.json`.
|
||||
'';
|
||||
};
|
||||
|
||||
userKeymaps = mkOption {
|
||||
type = jsonFormat.type;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
[
|
||||
{
|
||||
context = "Workspace";
|
||||
bindings = {
|
||||
ctrl-shift-t = "workspace::NewTerminal";
|
||||
};
|
||||
};
|
||||
]
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to Zed's {file}`keymap.json`.
|
||||
'';
|
||||
};
|
||||
|
||||
extensions = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
example = literalExpression ''
|
||||
[ "swift" "nix" "xy-zed" ]
|
||||
'';
|
||||
description = ''
|
||||
A list of the extensions Zed should install on startup.
|
||||
Use the name of a repository in the [extension list](https://github.com/zed-industries/extensions/tree/main/extensions).
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
xdg.configFile."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;
|
||||
});
|
||||
};
|
||||
}
|
|
@ -161,6 +161,7 @@ in import nmtSrc {
|
|||
./modules/programs/watson
|
||||
./modules/programs/wezterm
|
||||
./modules/programs/yazi
|
||||
./modules/programs/zed-editor
|
||||
./modules/programs/zellij
|
||||
./modules/programs/zk
|
||||
./modules/programs/zplug
|
||||
|
|
5
tests/modules/programs/zed-editor/default.nix
Normal file
5
tests/modules/programs/zed-editor/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
zed-extensions = ./extensions.nix;
|
||||
zed-keymap = ./keymap.nix;
|
||||
zed-settings = ./settings.nix;
|
||||
}
|
24
tests/modules/programs/zed-editor/extensions.nix
Normal file
24
tests/modules/programs/zed-editor/extensions.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
programs.zed-editor = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { };
|
||||
extensions = [ "swift" "html" "xy-zed" ];
|
||||
};
|
||||
|
||||
nmt.script = let
|
||||
expectedContent = builtins.toFile "expected.json" ''
|
||||
{
|
||||
"auto_install_extensions": {
|
||||
"html": true,
|
||||
"swift": true,
|
||||
"xy-zed": true
|
||||
}
|
||||
}
|
||||
'';
|
||||
in ''
|
||||
assertFileExists "home-files/.config/zed/settings.json"
|
||||
assertFileContent "home-files/.config/zed/settings.json" "${expectedContent}"
|
||||
'';
|
||||
}
|
39
tests/modules/programs/zed-editor/keymap.nix
Normal file
39
tests/modules/programs/zed-editor/keymap.nix
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Test custom keymap functionality
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
programs.zed-editor = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { };
|
||||
userKeymaps = [
|
||||
{ bindings = { up = "menu::SelectPrev"; }; }
|
||||
{
|
||||
context = "Editor";
|
||||
bindings = { escape = "editor::Cancel"; };
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
nmt.script = let
|
||||
expectedContent = builtins.toFile "expected.json" ''
|
||||
[
|
||||
{
|
||||
"bindings": {
|
||||
"up": "menu::SelectPrev"
|
||||
}
|
||||
},
|
||||
{
|
||||
"bindings": {
|
||||
"escape": "editor::Cancel"
|
||||
},
|
||||
"context": "Editor"
|
||||
}
|
||||
]
|
||||
'';
|
||||
|
||||
keymapPath = ".config/zed/keymap.json";
|
||||
in ''
|
||||
assertFileExists "home-files/${keymapPath}"
|
||||
assertFileContent "home-files/${keymapPath}" "${expectedContent}"
|
||||
'';
|
||||
}
|
36
tests/modules/programs/zed-editor/settings.nix
Normal file
36
tests/modules/programs/zed-editor/settings.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Test custom keymap functionality
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
programs.zed-editor = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { };
|
||||
userSettings = {
|
||||
theme = "XY-Zed";
|
||||
features = { copilot = false; };
|
||||
vim_mode = false;
|
||||
ui_font_size = 16;
|
||||
buffer_font_size = 16;
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = let
|
||||
expectedContent = builtins.toFile "expected.json" ''
|
||||
{
|
||||
"auto_install_extensions": {},
|
||||
"buffer_font_size": 16,
|
||||
"features": {
|
||||
"copilot": false
|
||||
},
|
||||
"theme": "XY-Zed",
|
||||
"ui_font_size": 16,
|
||||
"vim_mode": false
|
||||
}
|
||||
'';
|
||||
|
||||
settingsPath = ".config/zed/settings.json";
|
||||
in ''
|
||||
assertFileExists "home-files/${settingsPath}"
|
||||
assertFileContent "home-files/${settingsPath}" "${expectedContent}"
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue