summaryrefslogtreecommitdiff
path: root/src/lsp/lsp_client.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 22:31:27 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit7e8e2655567cab1c28597f44d0aec79e46b0deb8 (patch)
tree1dd74701cfcbd6b663170e86df854166ed0f0600 /src/lsp/lsp_client.zig
parent813a0b2bf3c110f2287d7136f0dfc540c0978cd6 (diff)
downloadpardes-7e8e2655567cab1c28597f44d0aec79e46b0deb8.tar.gz
pardes-7e8e2655567cab1c28597f44d0aec79e46b0deb8.zip
Zig files go to zls as a child process through the protocol client, as every other language does: the in-process ZLS backend goes
lsp_zls.zig (1,522 lines), the zls dependency, build.zig's zls wiring and the import graph it baked into the options only for it, and main.zig's reference go. lsp_client's table gains a zls row (PARDES_LSP_ZIG overrides it); Hover, Rename, Diagnostics, WsSymbols, Lspinfo and gd answer through it (checked with lspprobe and the snapshots against zls 0.16.1-dev). What changes for a user: zls must be on PATH; a completion's rows are zls's candidates at the cursor, where the linked analyser gave each one's declaration; document symbols carry no signature. The Zig snapshots (lsp, lspcomplete, lspcompletemoved, lspdebug, lsprelpath) run the real zls now: lspdebug reads the client's explain and report, lsprelpath spells gr's rows where it spelled a completion's, and their goldens are recorded again (stable over three runs). Lspinfo still opens with its backend line. The ReleaseFast tty binary is 105.35 MB to 96.28 MB, the Debug one 296.5 MB to 245.9 MB. docs/lsp.md, web.md, design.typ and the README say so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/lsp/lsp_client.zig')
-rw-r--r--src/lsp/lsp_client.zig18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/lsp/lsp_client.zig b/src/lsp/lsp_client.zig
index 7c1980f6..7704d0ad 100644
--- a/src/lsp/lsp_client.zig
+++ b/src/lsp/lsp_client.zig
@@ -1,9 +1,8 @@
//! A real Language Server Protocol client: child processes spoken to over
//! JSON-RPC 2.0 with `Content-Length` framing. Nothing here knows any single
//! language — `specs` is a table of (binary, languageId, extensions, root
-//! markers), and rust-analyzer, clangd and gopls are rows in it. The in-process
-//! ZLS backend keeps `.zig`; this file is every language pardes highlights but
-//! could not answer questions about.
+//! markers), and zls, rust-analyzer, clangd and gopls are rows in it: every
+//! language pardes answers questions about.
//!
//! THE PROCESS LIFECYCLE IS THE DESIGN. `lsp.query` is a synchronous call on a
//! worker thread, and a language server costs tens of milliseconds to start
@@ -104,6 +103,14 @@ const Spec = struct {
pub const specs = [_]Spec{
.{
+ .name = "zls",
+ .bin = "zls",
+ .lang = "zig",
+ .exts = &.{".zig"},
+ .markers = &.{ "build.zig", "build.zig.zon" },
+ .env = "PARDES_LSP_ZIG",
+ },
+ .{
.name = "rust-analyzer",
.bin = "rust-analyzer",
.lang = "rust",
@@ -147,8 +154,7 @@ pub const specs = [_]Spec{
},
};
-/// Everything, including the four hierarchy kinds the in-process backend has
-/// no analyser for. Whether one SERVER can answer is a capability question
+/// Everything. Whether one SERVER can answer is a capability question
/// answered per connection; a kind its server never advertised simply returns
/// no rows, which the harness reports as CLAIMED-EMPTY per language — honest,
/// since the claim here is about the protocol, not about every server.
@@ -2175,9 +2181,9 @@ test "rootOf takes the top-most marker and falls back to git then dir" {
test "specFor routes extensions and honours the disable env" {
try std.testing.expect(specFor("/x/main.rs") != null);
- try std.testing.expect(specFor("/x/main.zig") == null);
try std.testing.expect(specFor("/x/README.md") == null);
try std.testing.expectEqualStrings("rust-analyzer", specs[specFor("/x/main.rs").?].name);
+ if (getenv("PARDES_LSP_ZIG") == null) try std.testing.expectEqualStrings("zls", specs[specFor("/x/main.zig").?].name);
}
test "the transport this host actually gives us is a pair, and both ends are close-on-exec" {