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:
parent
72423471f1
commit
69ea495495
4 changed files with 18 additions and 4 deletions
|
@ -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 {
|
||||
|
|
|
@ -41,6 +41,8 @@ palette_style: WidgetStyle = .bars_top_bottom,
|
|||
panel_style: WidgetStyle = .compact,
|
||||
home_style: WidgetStyle = .bars_top_bottom,
|
||||
|
||||
lsp_output: enum { quiet, verbose } = .quiet,
|
||||
|
||||
include_files: []const u8 = "",
|
||||
|
||||
pub const DigitStyle = enum {
|
||||
|
|
|
@ -608,10 +608,11 @@ const Process = struct {
|
|||
return if (std.mem.eql(u8, method, "textDocument/publishDiagnostics"))
|
||||
project.publish_diagnostics(self.parent.ref(), params_cb)
|
||||
else if (std.mem.eql(u8, method, "window/showMessage"))
|
||||
project.show_message(self.parent.ref(), params_cb)
|
||||
project.show_message(params_cb)
|
||||
else if (std.mem.eql(u8, method, "window/logMessage"))
|
||||
project.show_message(self.parent.ref(), params_cb)
|
||||
project.log_message(params_cb)
|
||||
else {
|
||||
if (!tp.env.get().is("lsp_verbose")) return;
|
||||
const params = try cbor.toJsonAlloc(self.allocator, params_cb);
|
||||
defer self.allocator.free(params);
|
||||
self.logger.print("LSP notification: {s} -> {s}", .{ method, params });
|
||||
|
|
|
@ -122,6 +122,8 @@ fn init(allocator: Allocator) InitError!*Self {
|
|||
const frame_time = std.time.us_per_s / conf.frame_rate;
|
||||
const frame_clock = try tp.metronome.init(frame_time);
|
||||
|
||||
tp.env.get().set("lsp_verbose", conf.lsp_output == .verbose);
|
||||
|
||||
var self = try allocator.create(Self);
|
||||
// don't destroy
|
||||
// if tui fails it is catastrophic anyway and we don't want to cause nock-on errors
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue