Zed/en: Difference between revisions
Updating to match new version of source page |
Updating to match new version of source page |
||
| Line 17: | Line 17: | ||
}} | }} | ||
[https://zed.dev Zed]<ref>Zed Industries, "Zed", Official Website, Accessed October 2025. https://zed.dev</ref> is a collaborative, GPU-accelerated text editor developed by Zed Industries. It combines fast local editing with real-time multiplayer features and ships with batteries-included tooling for popular programming languages. | [https://zed.dev Zed]<ref>Zed Industries, "Zed", Official Website, Accessed October 2025. https://zed.dev</ref> is a collaborative, GPU-accelerated text editor developed by Zed Industries. It combines fast local editing with real-time multiplayer features and ships with batteries-included tooling for popular programming languages. | ||
The editor provides native builds for Linux, including Nixpkgs packages and a reproducible flake. Hardware acceleration requires a GPU with Vulkan support; systems without Vulkan can fall back to emulation via tools such as [https://github.com/nix-community/nixGL nixGL].<ref>Zed Industries, "Linux", Zed Documentation, Accessed October 2025. https://zed.dev/docs/linux</ref> | The editor provides native builds for Linux, including Nixpkgs packages and a reproducible flake. Hardware acceleration requires a GPU with Vulkan support; systems without Vulkan can fall back to emulation via tools such as [https://github.com/nix-community/nixGL nixGL].<ref>Zed Industries, "Linux", Zed Documentation, Accessed October 2025. https://zed.dev/docs/linux</ref> | ||
{{Nixpkg|pkgs/by-name/ze/zed-editor|zed-editor}} is available in Nixpkgs since 24.11; However, Zed provides [https://github.com/zed-industries/zed/blob/main/flake.nix an official nix flake] which might be useful if you need features that have not yet reached unstable Nixpkgs. | |||
== Installation == | == Installation == | ||
==== | The package installs both desktop launchers and a CLI entry point aliased to <code>zeditor</code>, mirroring the upstream binary name | ||
=== Imperative === | |||
==== Zed's Flake ==== | |||
<syntaxhighlight lang="console"> | |||
nix run github:zed-industries/zed | |||
</syntaxhighlight> | |||
==== Nixpkgs ==== | |||
<syntaxhighlight lang="console"> | |||
nix run nixpkgs#zed-editor | |||
</syntaxhighlight> | |||
=== Declarative === | |||
==== NixOS ==== | |||
<syntaxhighlight lang="nix"> | |||
environment.systemPackages = [ | environment.systemPackages = [ | ||
pkgs.zed-editor | pkgs.zed-editor | ||
]; | ]; | ||
</syntaxhighlight> | |||
{{Evaluate}} | |||
==== Home Manager ==== | |||
<syntaxhighlight lang="nix"> | |||
home.packages = [ | home.packages = [ | ||
pkgs.zed-editor | pkgs.zed-editor | ||
]; | ]; | ||
</syntaxhighlight> | |||
<syntaxhighlight lang="console"> | |||
home-manager switch | |||
</syntaxhighlight> | |||
==== Zed's Flake ==== | |||
== | <syntaxhighlight lang="nix"> | ||
{ | |||
inputs.zed.url = "github:zed-industries/zed"; | |||
outputs = | |||
{{ | { | ||
self, | |||
nixpkgs, | |||
zed, | |||
... | |||
}@inputs: | |||
let | |||
system = "x86_64-linux"; | |||
pkgs = import nixpkgs { inherit system; }; | |||
in | |||
{ | |||
packages.${system}.zed-latest = zed.packages.${system}.default; | |||
}; | |||
} | |||
</syntaxhighlight> | |||
Build the flake package with <code>nix build .#zed-latest</code> or expose it in your configuration with the appropriate overlay. | Build the flake package with <code>nix build .#zed-latest</code> or expose it in your configuration with the appropriate overlay. | ||
{{Warning|Zed requires hardware-accelerated Vulkan. On systems without supported drivers, use <code>nixGL</code> or home-manager's <code>nixGL.vulkan.enable {{=}} true;</code> to provide the necessary libraries. | |||
Providing Vulkan through <code>nixGL</code> can be more consistent than relying on host distribution packages, especially on non-NixOS systems where Wayland and X11 stacks differ in their Vulkan capabilities. | {{Warning|Zed requires hardware-accelerated Vulkan. On systems without supported drivers, use <code>nixGL</code> or home-manager's <code>nixGL.vulkan.enable {{=}} true;</code> to provide the necessary libraries. | ||
Providing Vulkan through <code>nixGL</code> can be more consistent than relying on host distribution packages, especially on non-NixOS systems where Wayland and X11 stacks differ in their Vulkan capabilities.}} | |||
== Configuration == | == Configuration == | ||
| Line 60: | Line 96: | ||
==== Basic ==== | ==== Basic ==== | ||
<syntaxhighlight lang="nix"> | |||
programs.zed-editor = { | |||
enable = true; | enable = true; | ||
extensions = [ "nix" "toml" "rust" ]; | extensions = [ "nix" "toml" "rust" ]; | ||
| Line 72: | Line 110: | ||
vim_mode = true; | vim_mode = true; | ||
}; | }; | ||
}; | }; | ||
</syntaxhighlight> | |||
The configuration above enables Zed via Home Manager, installs a small set of extensions, and synchronises the theme with the desktop appearance. | The configuration above enables Zed via Home Manager, installs a small set of extensions, and synchronises the theme with the desktop appearance. | ||
==== Advanced ==== | ==== Advanced ==== | ||
<syntaxhighlight lang="nix"> | |||
programs.zed-editor = { | programs.zed-editor = { | ||
enable = true; | enable = true; | ||
| Line 208: | Line 249: | ||
}; | }; | ||
}; | }; | ||
</syntaxhighlight> | |||
This example adds language servers to the FHS sandbox, enables the bundled assistant, configures the terminal, and ensures remote server binaries are provided declaratively. | This example adds language servers to the FHS sandbox, enables the bundled assistant, configures the terminal, and ensures remote server binaries are provided declaratively. | ||
| Line 218: | Line 260: | ||
== LSP support == | == LSP support == | ||
Zed downloads | Zed downloads LSP servers into <code>~/.local/share/zed/languages/</code>. These binaries most likely will not work because of linking issues. You can workaround this with the following methods or bring your own LSP servers. | ||
Check <strong>LSP Logs → Server Info</strong> to confirm which binaries are running | Check <strong>LSP Logs → Server Info</strong> to confirm which binaries are running. | ||
==== Nix-ld (recommended) ==== | ==== Nix-ld (recommended) ==== | ||
Enable [[FAQ#I've downloaded a binary, but I can't run it, what can I do?|<code>nix-ld</code>]] so | Enable [[FAQ#I've downloaded a binary, but I can't run it, what can I do?|<code>programs.nix-ld</code>]] so language servers downloaded by Zed can resolve dynamic libraries without wrapping and work out of the box. | ||
==== FHS wrapper ==== | ==== FHS wrapper ==== | ||
Use <code>pkgs.zed-editor.fhsWithPackages</code> to extend the FHS environment with additional system libraries when a language server requires them. | Use <code>pkgs.zed-editor.fhsWithPackages</code> to extend the FHS environment with additional system libraries when a language server requires them. | ||
Remember that language servers started inside the wrapper do not | <syntaxhighlight lang="nix"> | ||
pkgs.zed-editor.fhsWithPackages( | |||
pkgs: with pkgs; [ | |||
openssl | |||
zlib | |||
] | |||
) | |||
</syntaxhighlight> | |||
Remember that language servers started inside the wrapper do not inherit tools and libraries from nix shell. This is usually not desired because LSP may need project-level dependencies provided by nix-shell to compile and analyze the code. | |||
==== Bring your own LSP servers ==== | ==== Bring your own LSP servers ==== | ||
| Line 233: | Line 284: | ||
Nixpkgs versions of tools may be required for development on NixOS, especially for the C/C++ ecosystem. Check <strong>LSP Logs → Server Info</strong> to see which binaries are running. | Nixpkgs versions of tools may be required for development on NixOS, especially for the C/C++ ecosystem. Check <strong>LSP Logs → Server Info</strong> to see which binaries are running. | ||
If automatic detection doesn't work, specify the path manually in your Zed configuration: | If automatic detection doesn't work, specify the path manually in your Zed configuration: | ||
<syntaxhighlight lang="json"> | |||
{ | |||
"lsp": { | "lsp": { | ||
"rust-analyzer": { | "rust-analyzer": { | ||
| Line 242: | Line 295: | ||
} | } | ||
} | } | ||
</syntaxhighlight> | |||
Adjust the path for each language server you manage. The example above assumes rust-analyzer is installed in your system profile. | Adjust the path for each language server you manage. The example above assumes rust-analyzer is installed in your system profile. | ||
== Remote server == | == Remote server == | ||
Zed uploads a versioned remote server binary to <code>~/.zed_server</code> on the target host. The Nixpkgs package exposes the matching binary via the <code>remote_server</code> output. | Zed uploads a versioned remote server binary to <code>~/.zed_server</code> on the target host. The Nixpkgs package exposes the matching binary via the <code>remote_server</code> output. | ||
When you connect to a remote machine, the client either downloads a matching server binary from upstream or pushes a local copy if <code>"upload_binary_over_ssh": true</code> is enabled. Connections fail if the versions diverge. | When you connect to a remote machine, the client either downloads a matching server binary from upstream or pushes a local copy if <code>"upload_binary_over_ssh": true</code> is enabled. Connections fail if the versions diverge. | ||
<syntaxhighlight lang="nix"> | |||
home.file.".zed_server" = { | |||
source = "${pkgs.zed-editor.remote_server}/bin"; | source = "${pkgs.zed-editor.remote_server}/bin"; | ||
recursive = true; | recursive = true; | ||
}; | }; | ||
</syntaxhighlight> | |||
The <code>recursive = true;</code> setting keeps the directory writable while symlinking individual binaries, allowing Zed to add new versions when needed. This is necessary because the <code>~/.zed_server</code> folder is also used when external clients connect to the current system as a remote. | The <code>recursive = true;</code> setting keeps the directory writable while symlinking individual binaries, allowing Zed to add new versions when needed. This is necessary because the <code>~/.zed_server</code> folder is also used when external clients connect to the current system as a remote. | ||
Alternatively, use Home Manager's built-in option for simpler setup: | Alternatively, use Home Manager's built-in option for simpler setup: | ||
<syntaxhighlight lang="nix">programs.zed-editor = { | |||
enable = true; | enable = true; | ||
installRemoteServer = true; | installRemoteServer = true; | ||
}; | };</syntaxhighlight> | ||
To restrict remote clients to a specific server version, set <code>recursive = false;</code> to make the entire folder read-only. Zed refuses to connect if it cannot provision the required binary, so document the restriction for collaborators. | To restrict remote clients to a specific server version, set <code>recursive = false;</code> to make the entire folder read-only. Zed refuses to connect if it cannot provision the required binary, so document the restriction for collaborators. | ||
| Line 266: | Line 327: | ||
==== Preinstall extensions ==== | ==== Preinstall extensions ==== | ||
<syntaxhighlight lang="json"> | |||
{ | |||
"extensions": [ | "extensions": [ | ||
"nix", | "nix", | ||
| Line 273: | Line 335: | ||
] | ] | ||
} | } | ||
</syntaxhighlight> | |||
Declaratively listing extensions ensures they are installed automatically on new systems while still allowing additional extensions to be added interactively. | Declaratively listing extensions ensures they are installed automatically on new systems while still allowing additional extensions to be added interactively. | ||