radish: add zed

This commit is contained in:
Joakim Repomaa
2025-03-01 13:20:40 +02:00
parent 5c4e161076
commit a93d4afbcf
3 changed files with 174 additions and 4 deletions

View File

@@ -5,6 +5,7 @@
../custom-programs ../custom-programs
./neovim ./neovim
./dnote.nix ./dnote.nix
../modules/zed
inputs.hastebin.nixosModules.hm inputs.hastebin.nixosModules.hm
]; ];
@@ -110,7 +111,7 @@
enable = true; enable = true;
font = { font = {
name = "IosevkaTerm NFM"; name = "IosevkaTerm NFM";
size = 12; size = 14;
}; };
shellIntegration.enableZshIntegration = true; shellIntegration.enableZshIntegration = true;
themeFile = "Tomorrow_Night"; themeFile = "Tomorrow_Night";
@@ -207,9 +208,10 @@
}; };
os = { os = {
edit = "$EDITOR {{filename}}"; edit = "$EDITOR {{filename}}";
editAtLine = "$EDITOR +{{line}} {{filename}}"; editAtLine = "$EDITOR {{filename}}:{{line}}";
editAtLineAndWait = "$EDITOR --remote-wait +{{line}} {{filename}}"; editAtLineAndWait = "$EDITOR --wait {{filename}}:{{line}}";
}; };
promptToReturnFromSubprocess = false;
customCommands = [ customCommands = [
{ {
key = "<c-p>"; key = "<c-p>";
@@ -299,6 +301,10 @@
clipboard_command = "${pkgs.wl-copy-both}/bin/wl-copy"; clipboard_command = "${pkgs.wl-copy-both}/bin/wl-copy";
}; };
}; };
zed-editor = {
enable = true;
defaultEditor = true;
};
}; };
gnome = { gnome = {

View File

@@ -9,7 +9,7 @@
in in
{ {
enable = true; enable = true;
defaultEditor = true; defaultEditor = false;
options = { options = {
number = true; number = true;
expandtab = true; expandtab = true;

View File

@@ -0,0 +1,164 @@
{
inputs,
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.zed-editor;
in
{
options.programs.zed-editor = {
userTasks = lib.mkOption {
type = lib.types.listOf lib.types.attrs;
default = [ ];
};
defaultEditor = lib.mkOption {
type = lib.types.bool;
default = false;
};
};
config = lib.mkIf cfg.enable {
programs.zed-editor = {
package = inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.zed-editor;
extensions = [
"ruby"
"crystal"
"nix"
"svelte"
];
userSettings = {
node = {
path = lib.getExe pkgs.nodejs;
npm_path = lib.getExe' pkgs.nodejs "npm";
};
assistant = {
enabled = true;
version = "2";
default = "zed.dev";
default_model = {
provider = "zed.dev";
model = "claude-3-5-sonnet-latest";
};
};
autoUpdate = false;
telemetry = {
diagnostics = false;
metrics = false;
};
vim_mode = true;
languages = {
Ruby = {
language_servers = [
"ruby-lsp"
"!rubocop"
"!solargraph"
];
};
Nix = {
formatter.external = {
command = lib.getExe pkgs.nixfmt-rfc-style;
arguments = [ "-q" ];
};
};
};
lsp = with pkgs; {
nixd.binary.path = lib.getExe nixd;
nil.binary.path = lib.getExe nil;
ruby-lsp.binary.path = lib.getExe ruby-lsp;
yaml-language-server.binary.path = lib.getExe yaml-language-server;
json-language-server.binary = {
path = lib.getExe nodePackages.vscode-json-languageserver;
arguments = [ "--stdio" ];
};
package-version-server.binary.path =
lib.getExe
inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.package-version-server;
eslint.settings.onIgnoredFiles = "off";
};
load_direnv = "shell_hook";
theme = {
mode = "system";
light = "One Light";
dark = "One Dark";
};
terminal = {
line_height = "standard";
font_family = "IosevkaTerm Nerd Font";
};
show_edit_predictions = true;
buffer_font_family = "Iosevka Nerd Font";
buffer_font_size = 16;
ui_font_size = 17;
relative_line_numbers = true;
};
userKeymaps = [
{
context = "VimControl && !menu";
bindings = {
"space g" = [
"task::Spawn"
{
task_name = "lazygit";
reveal_target = "center";
}
];
"space r" = "pane::DeploySearch";
"space f" = [
"file_finder::Toggle"
{ separate_history = true; }
];
"space :" = "task::Spawn";
"g R" = "editor::FindAllReferences";
};
}
{
context = "Dock || Pane || Editor";
bindings = {
"ctrl-h" = [
"workspace::ActivatePaneInDirection"
"Left"
];
"ctrl-j" = [
"workspace::ActivatePaneInDirection"
"Down"
];
"ctrl-k" = [
"workspace::ActivatePaneInDirection"
"Up"
];
"ctrl-l" = [
"workspace::ActivatePaneInDirection"
"Right"
];
};
}
{
context = "Terminal";
bindings = {
"ctrl-p" = [
"terminal::SendKeystroke"
"ctrl-p"
];
};
}
];
userTasks = with pkgs; [
{
label = "lazygit";
command = "${lib.getExe lazygit} -p $ZED_WORKTREE_ROOT";
hide = "on_success";
}
];
};
xdg.configFile."zed/tasks.json".text = builtins.toJSON cfg.userTasks;
home.sessionVariables = lib.mkIf cfg.defaultEditor {
EDITOR = lib.getExe pkgs.zed-editor;
};
};
}