From bb2b58c3149b9e4ff5fe17f3eef991f28b340b21 Mon Sep 17 00:00:00 2001 From: Mat Jones Date: Mon, 16 Sep 2024 08:22:06 -0400 Subject: [PATCH] feat: Add Zed editor --- home-manager/home.nix | 2 + home-manager/modules/zed.nix | 96 +++++++++++++++++++++++++++++++++++ home-manager/modules/zed.nix~ | 4 ++ 3 files changed, 102 insertions(+) create mode 100644 home-manager/modules/zed.nix create mode 100644 home-manager/modules/zed.nix~ diff --git a/home-manager/home.nix b/home-manager/home.nix index 868448cc..d27f90f8 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -55,6 +55,7 @@ in { r2modman parsec-bin notesnook + zed-editor # macOS package is broken, install manually there ]; file."${config.home.homeDirectory}/.xprofile".text = '' export XDG_DATA_DIRS="$XDG_DATA_DIRS:/home/mat/.nix-profile/share" @@ -88,6 +89,7 @@ in { ./modules/wezterm.nix ./modules/librewolf.nix ./modules/gnome + ./modules/zed.nix ./modules/recyclarr.nix ../nixos-modules/allowed-unfree.nix ]; diff --git a/home-manager/modules/zed.nix b/home-manager/modules/zed.nix new file mode 100644 index 00000000..6665826f --- /dev/null +++ b/home-manager/modules/zed.nix @@ -0,0 +1,96 @@ +{ pkgs, ... }: { + home.packages = with pkgs; [ + nixfmt + statix + shfmt + prettierd + rustfmt + rust-analyzer + gopls + shellcheck + maple-mono + (nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; }) + ]; + + xdg.configFile."zed/settings.json".text = builtins.toJSON { + telemetry = { + diagnostics = false; + metrics = false; + }; + features = { + # disable github copilot + inline_completion_provider = "none"; + }; + vim_mode = true; + ui_font_size = 16; + buffer_font_size = 16; + buffer_font_family = "Maple Mono"; + buffer_font_fallbacks = [ "Symbols Nerd Font Mono" ]; + buffer_font_features = { + cv03 = true; + ss01 = true; + ss02 = true; + ss04 = true; + ss05 = true; + }; + cursor_blink = false; + tabs = { + git_status = true; + file_icons = true; + }; + search = { regex = true; }; + theme = { + mode = "dark"; + light = "One Light"; # theme doesn't work without this for some reason + dark = "Tokyo Night Storm"; + }; + terminal = { line_height = { custom = 1; }; }; + languages = { + nix = { + format_on_save = true; + language_servers = [ "nil" ]; + formatter = { + external = { + command = "nixfmt"; + arguments = [ ]; + }; + }; + }; + }; + }; + xdg.configFile."zed/keymap.json".text = builtins.toJSON [ + { + context = "Editor && vim_mode == normal"; + bindings = { + F = "editor::ToggleCodeActions"; + gh = "editor::Hover"; + tab = [ "workspace::SendKeystrokes" "ctrl-pagedown" ]; + shift-tab = [ "workspace::SendKeystrokes" "ctrl-pageup" ]; + ctrl-h = [ "workspace::ActivatePaneInDirection" "Left" ]; + ctrl-j = [ "workspace::ActivatePaneInDirection" "Down" ]; + ctrl-k = [ "workspace::ActivatePaneInDirection" "Up" ]; + ctrl-l = [ "workspace::ActivatePaneInDirection" "Right" ]; + }; + } + { + context = "Dock"; + bindings = { + ctrl-h = [ "workspace::ActivatePaneInDirection" "Left" ]; + ctrl-l = [ "workspace::ActivatePaneInDirection" "Right" ]; + ctrl-k = [ "workspace::ActivatePaneInDirection" "Up" ]; + ctrl-j = [ "workspace::ActivatePaneInDirection" "Down" ]; + }; + } + { + context = "Editor && (showing_code_actions || showing_completions)"; + bindings = { + tab = "editor::ContextMenuNext"; + shift-tab = "editor::ContextMenuPrev"; + }; + } + { + context = "Editor && vim_mode == insert"; + bindings = { "j k" = [ "workspace::SendKeystrokes" "escape" ]; }; + } + ]; +} diff --git a/home-manager/modules/zed.nix~ b/home-manager/modules/zed.nix~ new file mode 100644 index 00000000..78e98efc --- /dev/null +++ b/home-manager/modules/zed.nix~ @@ -0,0 +1,4 @@ +{ isLinux, pkgs, ... }: +{ + +} // pkgs.lib.optionalAttrs isLinux { home.packages = [ pkgs.zed-editor ]; }