diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 22:31:27 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | 7e8e2655567cab1c28597f44d0aec79e46b0deb8 (patch) | |
| tree | 1dd74701cfcbd6b663170e86df854166ed0f0600 /src/lsp/lsp.zig | |
| parent | 813a0b2bf3c110f2287d7136f0dfc540c0978cd6 (diff) | |
| download | pardes-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.zig')
| -rw-r--r-- | src/lsp/lsp.zig | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lsp/lsp.zig b/src/lsp/lsp.zig index 7e5595fd..43f94f95 100644 --- a/src/lsp/lsp.zig +++ b/src/lsp/lsp.zig @@ -33,12 +33,14 @@ pub const Req = struct { root: []const u8 = "", }; -const backends = if (@import("pardes_config").zls_backend) - .{ @import("lsp_zls.zig"), @import("lsp_client.zig") } +/// Every language, Zig's (zls) included, through the protocol client, which +/// runs its server as a child process. None on the web or the board. +const backends = if (@import("pardes_config").platform == .web or @import("pardes_config").platform == .esp32p4) + .{} else - .{}; + .{@import("lsp_client.zig")}; -pub const backend_name = if (backends.len > 1) "zls-inproc+lsp-client" else "zls-inproc"; +pub const backend_name = "lsp-client"; pub const supports: std.EnumSet(Kind) = blk: { var s: std.EnumSet(Kind) = .initEmpty(); @@ -53,6 +55,7 @@ pub fn speaks(path: []const u8) bool { pub fn query(gpa: std.mem.Allocator, arena: std.mem.Allocator, req: Req, out: *std.Io.Writer) !void { if (req.kind == .status) { + try out.print("backend: {s}\n", .{backend_name}); inline for (backends) |b| try b.query(gpa, arena, req, out); return; } @@ -77,7 +80,7 @@ pub fn none(out: *std.Io.Writer, comptime fmt: []const u8, args: anytype) std.Io // Called on server reader threads; the sink must copy text before returning. pub fn setStatusSink(ctx: ?*anyopaque, cb: ?*const fn (ctx: ?*anyopaque, text: []const u8) void) void { - if (@import("pardes_config").zls_backend) backends[1].setStatusSink(ctx, cb); + inline for (backends) |b| b.setStatusSink(ctx, cb); } pub fn rel(base: []const u8, path: []const u8) []const u8 { @@ -164,7 +167,7 @@ test "a question no backend answers for a file says why rather than find nothing defer arena.deinit(); var buf: [256]u8 = undefined; var out: std.Io.Writer = .fixed(&buf); - // The in-process ZLS answers no call hierarchy for a .zig file. - try query(std.testing.allocator, arena.allocator(), .{ .kind = .incoming_calls, .path = "/x/main.zig", .source = "", .offset = 0 }, &out); + // A file no server speaks for is answered, not left empty. + try query(std.testing.allocator, arena.allocator(), .{ .kind = .incoming_calls, .path = "/x/notes.txt", .source = "", .offset = 0 }, &out); try std.testing.expectStringStartsWith(out.buffered(), "@none "); } |
