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, 12 insertions, 5 deletions
diff --git a/src/lsp/lsp.zig b/src/lsp/lsp.zig
index 4a70efe5..1c1b57a2 100644
--- a/src/lsp/lsp.zig
+++ b/src/lsp/lsp.zig
@@ -26,6 +26,10 @@ pub const Kind = enum {
};
pub const callstack_match = "@callstack-match ";
+/// The last row of a Callstack page that stopped full: `<path> <callers>`,
+/// the entry indices from the top the next page starts at (`3.0.17`), and
+/// how many callers this page holds.
+pub const callstack_more = "@callstack-more ";
pub const CallstackCorners = enum { rounded, square };
pub const callstack_default_depth: u8 = 8;
pub const callstack_max_depth: u8 = 64;
@@ -46,6 +50,9 @@ pub const Req = struct {
/// For `explain`: the query it narrates, read from `arg` (`<kind>
/// <arg>`) by `explaining`; a definition when none was asked before.
explains: Kind = .definition,
+ /// The fixed region `arena` allocates from, when it is one: a walk that
+ /// can grow (Callstack) reads how much is left and stops in time.
+ budget: ?*const std.heap.FixedBufferAllocator = null,
};
pub const Doc = struct { path: []const u8, source: [:0]const u8 };
@@ -102,18 +109,18 @@ pub fn speaks(path: []const u8) bool {
return false;
}
-pub fn query(gpa: std.mem.Allocator, arena: std.mem.Allocator, req: Req, out: *std.Io.Writer) !void {
+pub fn query(io: std.Io, 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);
+ inline for (backends) |b| try b.query(io, gpa, arena, req, out);
return;
}
inline for (backends) |b| {
if (b.speaks(req.path) and b.supports.contains(req.kind))
- return b.query(gpa, arena, req, out);
+ return b.query(io, gpa, arena, req, out);
}
if (req.kind == .explain and backends.len > 0)
- return backends[0].query(gpa, arena, req, out);
+ return backends[0].query(io, gpa, arena, req, out);
// Nothing asked: said why, where an empty answer would read as nothing
// found.
inline for (backends) |b| if (b.speaks(req.path))
@@ -217,6 +224,6 @@ test "a question no backend answers for a file says why rather than find nothing
var buf: [256]u8 = undefined;
var out: std.Io.Writer = .fixed(&buf);
// 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 query(std.testing.io, std.testing.allocator, arena.allocator(), .{ .kind = .incoming_calls, .path = "/x/notes.txt", .source = "", .offset = 0 }, &out);
try std.testing.expectStringStartsWith(out.buffered(), "@none ");
}