feat: respond to client/registerCapability requests with a null result
This commit is contained in:
parent
79ba5d32cd
commit
2060588a28
2 changed files with 22 additions and 7 deletions
|
@ -749,6 +749,18 @@ pub fn show_message(_: *Self, _: tp.pid_ref, params_cb: []const u8) !void {
|
|||
logger.print("{s}", .{msg});
|
||||
}
|
||||
|
||||
pub fn register_capability(self: *Self, from: tp.pid_ref, id: i32, params_cb: []const u8) !void {
|
||||
_ = params_cb;
|
||||
return self.send_lsp_response(from, id, null);
|
||||
}
|
||||
|
||||
pub fn send_lsp_response(self: *Self, from: tp.pid_ref, id: i32, result: anytype) !void {
|
||||
var cb = std.ArrayList(u8).init(self.allocator);
|
||||
defer cb.deinit();
|
||||
try cbor.writeValue(cb.writer(), result);
|
||||
return from.send(.{ "RSP", id, cb.items });
|
||||
}
|
||||
|
||||
fn send_lsp_init_request(self: *Self, lsp: LSP, project_path: []const u8, project_basename: []const u8, project_uri: []const u8) !tp.message {
|
||||
return lsp.send_request(self.allocator, "initialize", .{
|
||||
.processId = if (builtin.os.tag == .linux) std.os.linux.getpid() else null,
|
||||
|
|
|
@ -258,7 +258,7 @@ const Process = struct {
|
|||
} else if (try m.match(.{ "child", tp.extract(&project_directory), tp.extract(&language_server), "notify", tp.extract(&method), tp.extract_cbor(¶ms_cb) })) {
|
||||
self.dispatch_notify(project_directory, language_server, method, params_cb) catch |e| return self.logger.err("lsp-handling", e);
|
||||
} else if (try m.match(.{ "child", tp.extract(&project_directory), tp.extract(&language_server), "request", tp.extract(&method), tp.extract(&id), tp.extract_cbor(¶ms_cb) })) {
|
||||
self.dispatch_request(project_directory, language_server, method, id, params_cb) catch |e| return self.logger.err("lsp-handling", e);
|
||||
self.dispatch_request(from, project_directory, language_server, method, id, params_cb) catch |e| return self.logger.err("lsp-handling", e);
|
||||
} else if (try m.match(.{ "child", tp.extract(&path), "done" })) {
|
||||
self.logger.print_err("lsp-handling", "child '{s}' terminated", .{path});
|
||||
} else if (try m.match(.{ "open", tp.extract(&project_directory) })) {
|
||||
|
@ -468,13 +468,16 @@ const Process = struct {
|
|||
tp.exit_fmt("unsupported LSP notification: {s}", .{method});
|
||||
}
|
||||
|
||||
fn dispatch_request(self: *Process, project_directory: []const u8, language_server: []const u8, method: []const u8, id: i32, params_cb: []const u8) !void {
|
||||
_ = self;
|
||||
_ = project_directory;
|
||||
fn dispatch_request(self: *Process, from: tp.pid_ref, project_directory: []const u8, language_server: []const u8, method: []const u8, id: i32, params_cb: []const u8) !void {
|
||||
_ = language_server;
|
||||
_ = id;
|
||||
_ = params_cb;
|
||||
return tp.exit_fmt("unsupported LSP request: {s}", .{method});
|
||||
const project = if (self.projects.get(project_directory)) |p| p else return tp.exit("No project");
|
||||
return if (std.mem.eql(u8, method, "client/registerCapability"))
|
||||
project.register_capability(from, id, params_cb)
|
||||
else blk: {
|
||||
const params = try cbor.toJsonAlloc(self.allocator, params_cb);
|
||||
defer self.allocator.free(params);
|
||||
break :blk tp.exit_fmt("unsupported LSP request: {s} -> {s}", .{ method, params });
|
||||
};
|
||||
}
|
||||
|
||||
fn persist_projects(self: *Process) void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue