mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 06:59:22 +01:00
953ac75529
I'm continuing the work of @lolpack's PR https://github.com/zed-industries/zed/pull/40953. This makes it such that user no longer needs to install the external pyrefly extension to use pyrefly. It also auto-downloads Pyrefly binary when there's no existing installation, which the pyrefly extension currently can't do. We don't publish Pyrefly release artifacts to github (yet), so the easiest way to obtain a Pyrefly installation is with PyPI. Given that the PyLSP adapter is already doing a PyPI-based installation, I've essentially copy&pasted most of the logic from there into pyrefly adapter so Pyrefly could work in exactly the same way for now. There are a lot of code duplications here! My thought was to get the functionality in first, and I can send followup PRs to extract duplicated code into common helper functions. I tested the change in 2 scenarios: - No `pyrefly` binary is found in `$PATH` - There's an existing `pyrefly` binary in `$PATH` -- I obtained it with `uv tool install pyrefly`. In both scenarios I ran the test by removing the Pyrefly exteranl plugin, start Zed, open a `.py` file with type errors in it, and verify that cmd-click (gotodef) works. Console output for scenario 1: ``` > cargo run Blocking waiting for file lock on package cache Blocking waiting for file lock on package cache Blocking waiting for file lock on package cache Finished `dev` profile [unoptimized + debuginfo] target(s) in 31.62s Running `target/debug/zed` 2025-12-04T20:58:07-08:00 INFO [zed] ========== starting zed version 0.217.0+dev.65f328bd614282c1c370672106a9a279f8f22a3a, sha 65f328b ========== 2025-12-04T20:58:08-08:00 WARN [zed::reliability] Minidump endpoint not set 2025-12-04T20:58:08-08:00 INFO [extension_host] extensions updated. loading 2, reloading 0, unloading 0 2025-12-04T20:58:08-08:00 WARN [audio::audio_settings] Denoise does not work on debug builds, not enabling 2025-12-04T20:58:08-08:00 INFO [workspace] Rendered first frame 2025-12-04T20:58:09-08:00 WARN [audio::audio_settings] Denoise does not work on debug builds, not enabling 2025-12-04T20:58:16-08:00 INFO [lsp] starting language server process. binary path: "/Users/grievejia/Library/Application Support/Zed/languages/ruff/ruff-0.14.8/ruff-aarch64-apple-darwin/ruff", working directory: "/Users/grievejia/scratch/pyre_test", args: ["server"] 2025-12-04T20:58:20-08:00 INFO [lsp] starting language server process. binary path: "/Users/grievejia/Library/Application Support/Zed/languages/pyrefly/pyrefly-venv/bin/pyrefly", working directory: "/Users/grievejia/scratch/pyre_test", args: ["lsp"] ... ``` We could see that the venv installation is successful and the auto-installed Pyrefly binary is used. Console output for scenario 2: ``` > cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 29.62s Running `target/debug/zed` 2025-12-04T21:01:26-08:00 INFO [zed] ========== starting zed version 0.217.0+dev.65f328bd614282c1c370672106a9a279f8f22a3a, sha 65f328b ========== 2025-12-04T21:01:27-08:00 WARN [zed::reliability] Minidump endpoint not set 2025-12-04T21:01:27-08:00 INFO [extension_host] extensions updated. loading 2, reloading 0, unloading 0 2025-12-04T21:01:27-08:00 WARN [audio::audio_settings] Denoise does not work on debug builds, not enabling 2025-12-04T21:01:27-08:00 INFO [workspace] Rendered first frame 2025-12-04T21:01:28-08:00 WARN [audio::audio_settings] Denoise does not work on debug builds, not enabling 2025-12-04T21:01:34-08:00 INFO [language] found user-installed language server for pyrefly. path: "/Users/grievejia/.local/bin/pyrefly", arguments: ["lsp"] 2025-12-04T21:01:34-08:00 INFO [lsp] starting language server process. binary path: "/Users/grievejia/.local/bin/pyrefly", working directory: "/Users/grievejia/scratch/pyre_test", args: ["lsp"] ``` We could see that the correct installed Pyrefly binary was picked up. Release Notes: - Added Pyrefly as builtin language server option --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>