# ABOUTME: Installs the Zed editor and seeds its user configuration. # ABOUTME: nix-ld is what makes the language servers Zed downloads run here. { pkgs, ... }: let # Zed rewrites this file whenever a setting is changed from its UI, so it is # copied into the home directory rather than linked from the store. zedSettings = pkgs.writeText "zed-settings.json" '' { "cli_default_open_behavior": "new_window", "reduce_motion": "on", "edit_predictions": { "provider": "none" }, "project_panel": { "dock": "left" }, "outline_panel": { "dock": "left" }, "git_panel": { "dock": "left" }, "base_keymap": "SublimeText", "cursor_shape": "block", "ui_font_size": 14, "ui_font_family": "UbuntuSans Nerd Font", "ui_font_features": { "calt": true }, "buffer_font_family": "UbuntuSansMono Nerd Font", "buffer_font_size": 14, "theme": { "mode": "system", "light": "Catppuccin Latte", "dark": "Catppuccin Mocha" }, "telemetry": { "diagnostics": false, "metrics": false }, "terminal": { "shell": { "program": "zsh" }, // LC_MESSAGES=C keeps tool output (git, pytest, ruff) in English so it // stays greppable. Number and date formatting follows the system LANG. "env": { "LC_MESSAGES": "C" } }, "show_edit_predictions": false, "toolbar": { "quick_actions": false }, "agent": { "dock": "right", "enabled": false, "button": false }, "chat_panel": { "button": "never" }, "collaboration_panel": { "dock": "left", "button": false }, "auto_install_extensions": { "catppuccin": true, "dockerfile": true, "git-firefly": true, "html": true, "log": true, "nix": true, "php": true, "scss": true, "vue": true }, "languages": { "Python": { // ruff formats and organizes imports, basedpyright does type checking. // The other three bundled servers are disabled explicitly: without the // negations the "..." placeholder pulls in pyright, pylsp and ty as well, // which means four type checkers reporting on the same file. "language_servers": [ "ruff", "basedpyright", "!pyright", "!pylsp", "!ty", "..." ], "formatter": { "language_server": { "name": "ruff" } }, "code_actions_on_format": { "source.organizeImports.ruff": true } }, "JavaScript": { "code_actions_on_format": { "source.fixAll.eslint": true } }, "TypeScript": { "code_actions_on_format": { "source.fixAll.eslint": true } }, "TSX": { "code_actions_on_format": { "source.fixAll.eslint": true } }, "PHP": { // Intelephense without a licence key: completion, diagnostics, hover, // formatting and find-all-references are covered. Rename, code actions // and inlay hints stay locked behind the paid tier. "language_servers": [ "intelephense", "!phpactor", "!phptools", "!phpantom", "..." ] } }, "lsp": { "rust-analyzer": { "initialization_options": { "check": { "command": "clippy" } } } } } ''; in { # CLI entry point is `zeditor`, not `zed`. Needs working Vulkan, the GUI does # not start without it. environment.systemPackages = [ pkgs.zed-editor ]; # Zed downloads its language servers into ~/.local/share/zed/languages/ and # those binaries expect an FHS layout that does not exist here. nix-ld # supplies the loader they look for — the route the NixOS wiki recommends, # over zed-editor.fhsWithPackages, which would cut the servers off from # project-level tooling coming out of a nix-shell. programs.nix-ld.enable = true; systemd.user.tmpfiles.rules = [ "C %h/.config/zed/settings.json 0644 - - - ${zedSettings}" ]; }