feat: add config option lsp_output "quiet" to reduce LSP log verbosity

Set the option to "verbose" to re-enable logging of LSP show/logMessage requests.
This commit is contained in:
CJ van den Berg 2025-08-20 21:00:24 +02:00
parent 72423471f1
commit 69ea495495
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 18 additions and 4 deletions

View file

@ -1530,7 +1530,16 @@ fn read_position(position: []const u8) !Position {
return .{ .line = line.?, .character = character.? };
}
pub fn show_message(self: *Self, _: tp.pid_ref, params_cb: []const u8) !void {
pub fn show_message(self: *Self, params_cb: []const u8) !void {
return self.show_or_log_message(.show, params_cb);
}
pub fn log_message(self: *Self, params_cb: []const u8) !void {
return self.show_or_log_message(.log, params_cb);
}
fn show_or_log_message(self: *Self, operation: enum { show, log }, params_cb: []const u8) !void {
if (!tp.env.get().is("lsp_verbose")) return;
var type_: i32 = 0;
var message: ?[]const u8 = null;
var iter = params_cb;
@ -1550,7 +1559,7 @@ pub fn show_message(self: *Self, _: tp.pid_ref, params_cb: []const u8) !void {
if (type_ <= 2)
self.logger_lsp.err_msg("lsp", msg)
else
self.logger_lsp.print("{s}", .{msg});
self.logger_lsp.print("{s}: {s}", .{ @tagName(operation), msg });
}
pub fn register_capability(self: *Self, from: tp.pid_ref, cbor_id: []const u8, params_cb: []const u8) ClientError!void {