Zed/en: Difference between revisions

FuzzyBot (talk | contribs)
Updating to match new version of source page
 
FuzzyBot (talk | contribs)
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 ==


==== Shell ====
The package installs both desktop launchers and a CLI entry point aliased to <code>zeditor</code>, mirroring the upstream binary name
{{code|lang=bash|line=no|1=$ nix-shell -p zed-editor}}
 
The <code>zed-editor</code> package is available in Nixpkgs from channel 24.11 onward. The command above provides <code>zed-editor</code> in the current shell session without modifying any configuration files.
=== 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 ===


The package installs both desktop launchers and a CLI entry point aliased to <code>zeditor</code>, mirroring the upstream binary name.
==== NixOS ====


==== System setup ====
<syntaxhighlight lang="nix">
{{code|lang=nix|line=no|1=# In /etc/nixos/configuration.nix
environment.systemPackages = [
environment.systemPackages = [
   pkgs.zed-editor
   pkgs.zed-editor
];
];
</syntaxhighlight>
{{Evaluate}}
==== Home Manager ====


# In home-manager configuration (home.nix)
<syntaxhighlight lang="nix">
home.packages = [
home.packages = [
   pkgs.zed-editor
   pkgs.zed-editor
];
];
}}
</syntaxhighlight>
Rebuild your system or Home Manager profile to make Zed available persistently. On NixOS, run <code>sudo nixos-rebuild switch</code>; for Home Manager, run <code>home-manager switch</code>.
 
<syntaxhighlight lang="console">
home-manager switch
</syntaxhighlight>
 
==== Zed's Flake ====


==== Flake ====
<syntaxhighlight lang="nix">
{
  inputs.zed.url = "github:zed-industries/zed";


Zed maintains an official flake for tracking the latest upstream build. This approach is useful if you need features that have not yet reached stable Nixpkgs.
  outputs =
{{code|lang=nix|line=no|1=inputs.zed.url = "github:zed-industries/zed";
    {
      self,
      nixpkgs,
      zed,
      ...
    }@inputs:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };
    in
    {
      packages.${system}.zed-latest = zed.packages.${system}.default;
    };
}
</syntaxhighlight>


outputs = { self, nixpkgs, zed, ... }@inputs: let
  system = "x86_64-linux";
  pkgs = import nixpkgs { inherit system; };
in {
  packages.${system}.zed-latest = zed.packages.${system}.default;
};}}
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 ====
{{code|lang=nix|line=no|1=programs.zed-editor = {
 
<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 ====
{{code|lang=nix|line=no|1=
 
<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 language servers into <code>~/.local/share/zed/languages/</code>, which is read-only on NixOS. Instead, use declarative methods to supply LSP binaries.
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. Prefer language servers packaged in Nixpkgs so that dependencies are resolved within the Nix store.
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 prebuilt language servers can resolve dynamic libraries without wrapping.
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.
{{code|lang=nix|line=no|1=pkgs.zed-editor.fhsWithPackages (pkgs: with pkgs; [ openssl zlib ])}}
 
Remember that language servers started inside the wrapper do not automatically inherit tools from ad-hoc shells; include every dependency declaratively.
<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:
{{code|lang=json|line=no|1={
 
<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.
{{code|lang=nix|line=no|1=home.file.".zed_server" = {
 
<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:
{{code|lang=nix|line=no|1=programs.zed-editor = {
 
<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 ====
{{code|lang=json|line=no|1={
<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.