summaryrefslogtreecommitdiff
path: root/src/lsp/lsp.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/lsp/lsp.zig')
-rw-r--r--src/lsp/lsp.zig17
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 ");
}