From ced915fedc99eeffbf4c5b1df68895c1514de412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20T=C3=A1mara?= Date: Sun, 16 Nov 2025 19:04:32 -0500 Subject: [PATCH 1/5] refactor: Removed unused lsp symbol struct --- src/Project.zig | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Project.zig b/src/Project.zig index e47ac48..dd401fb 100644 --- a/src/Project.zig +++ b/src/Project.zig @@ -1867,15 +1867,6 @@ const DocumentSymbol = struct { parent_name: []const u8 = &.{}, }; -const SymbolInformation = struct { - name: []const u8, - kind: usize, - tags: ?[]const usize, - deprecated: ?bool, - location: Location, - containerName: ?[]const u8, -}; - // Location is a subset of LocationLink const Location = LocationLink; From c5e6d64235d7f0c6c6589f8d78f1d7f11ec03b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20T=C3=A1mara?= Date: Sun, 16 Nov 2025 19:54:17 -0500 Subject: [PATCH 2/5] refactor: make available write_padding function to other modules --- build.zig | 2 ++ src/list_languages.zig | 12 +++--------- src/text_manip.zig | 9 +++++++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/build.zig b/build.zig index 1b194ed..1b3a01f 100644 --- a/build.zig +++ b/build.zig @@ -668,6 +668,7 @@ pub fn build_exe( exe.root_module.addImport("flags", flags_dep.module("flags")); exe.root_module.addImport("cbor", cbor_mod); exe.root_module.addImport("config", config_mod); + exe.root_module.addImport("text_manip", text_manip_mod); exe.root_module.addImport("Buffer", Buffer_mod); exe.root_module.addImport("tui", tui_mod); exe.root_module.addImport("thespian", thespian_mod); @@ -717,6 +718,7 @@ pub fn build_exe( check_exe.root_module.addImport("flags", flags_dep.module("flags")); check_exe.root_module.addImport("cbor", cbor_mod); check_exe.root_module.addImport("config", config_mod); + check_exe.root_module.addImport("text_manip", text_manip_mod); check_exe.root_module.addImport("Buffer", Buffer_mod); check_exe.root_module.addImport("tui", tui_mod); check_exe.root_module.addImport("thespian", thespian_mod); diff --git a/src/list_languages.zig b/src/list_languages.zig index 376424c..7e42190 100644 --- a/src/list_languages.zig +++ b/src/list_languages.zig @@ -1,5 +1,8 @@ const std = @import("std"); const file_type_config = @import("file_type_config"); +const text_manip = @import("text_manip"); +const write_string = text_manip.write_string; +const write_padding = text_manip.write_padding; const builtin = @import("builtin"); const RGB = @import("color").RGB; @@ -66,11 +69,6 @@ fn args_string_length(args_: ?[]const []const u8) usize { return len; } -fn write_string(writer: anytype, string: []const u8, pad: ?usize) !void { - try writer.writeAll(string); - if (pad) |pad_| try write_padding(writer, string.len, pad_); -} - fn write_checkmark(writer: anytype, success: bool, tty_config: std.io.tty.Config) !void { try tty_config.setColor(writer, if (success) .green else .red); if (success) try writer.writeAll(success_mark) else try writer.writeAll(fail_mark); @@ -98,10 +96,6 @@ fn write_segmented( if (pad) |pad_| try write_padding(writer, len, pad_); } -fn write_padding(writer: anytype, len: usize, pad_len: usize) !void { - for (0..pad_len - len) |_| try writer.writeAll(" "); -} - fn can_execute(allocator: std.mem.Allocator, binary_name: []const u8) bool { const resolved_binary_path = bin_path.find_binary_in_path(allocator, binary_name) catch return false; defer if (resolved_binary_path) |path| allocator.free(path); diff --git a/src/text_manip.zig b/src/text_manip.zig index 1202095..2197315 100644 --- a/src/text_manip.zig +++ b/src/text_manip.zig @@ -89,3 +89,12 @@ pub fn toggle_prefix_in_text(prefix: []const u8, text: []const u8, allocator: st } return result.toOwnedSlice(allocator); } + +pub fn write_string(writer: anytype, string: []const u8, pad: ?usize) !void { + try writer.writeAll(string); + if (pad) |pad_| try write_padding(writer, string.len, pad_); +} + +pub fn write_padding(writer: anytype, len: usize, pad_len: usize) !void { + for (0..pad_len - len) |_| try writer.writeAll(" "); +} From 0fd1cae8df1aa146d5b1445902e8f0dd6b7af391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20T=C3=A1mara?= Date: Mon, 17 Nov 2025 00:23:23 -0500 Subject: [PATCH 3/5] refactor: symbol palette column max width change --- src/tui/mode/overlay/symbol_palette.zig | 36 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/tui/mode/overlay/symbol_palette.zig b/src/tui/mode/overlay/symbol_palette.zig index 436e49f..47e8d74 100644 --- a/src/tui/mode/overlay/symbol_palette.zig +++ b/src/tui/mode/overlay/symbol_palette.zig @@ -3,6 +3,9 @@ const fmt = std.fmt; const cbor = @import("cbor"); const tp = @import("thespian"); const root = @import("soft_root").root; +const text_manip = @import("text_manip"); +const write_string = text_manip.write_string; +const write_padding = text_manip.write_padding; const command = @import("command"); const Buffer = @import("Buffer"); @@ -42,21 +45,21 @@ pub fn load_entries(palette: *Type) !usize { (try palette.entries.addOne(palette.allocator)).* = .{ .cbor = cbor_item, .label = undefined, .row = undefined }; } - var max_label_len: usize = 0; - var max_parent_len: usize = 0; - var max_kind_len: usize = 0; + var max_name_len: usize = 4; + var max_parent_len: usize = 4; + var max_kind_len: usize = 4; for (palette.entries.items) |*item| { const label_, const parent_, const kind, const row, _ = get_values(item.cbor); item.label = label_; item.row = row; - max_label_len = @max(max_label_len, item.label.len); + max_name_len = @max(max_name_len, item.label.len); max_parent_len = @max(max_parent_len, parent_.len); max_kind_len = @max(max_kind_len, kind_name(@enumFromInt(kind)).len); } - palette.value.min_col_name = @min(palette.value.min_col_name, max_label_len); - palette.value.min_col_parent = @min(palette.value.min_col_parent, max_parent_len); - palette.value.min_col_kind = @min(palette.value.min_col_kind, max_kind_len); + palette.value.min_col_name = @min(26, max_name_len); + palette.value.min_col_parent = @min(14, max_parent_len); + palette.value.min_col_kind = @min(12, max_kind_len); const less_fn = struct { fn less_fn(_: void, lhs: Entry, rhs: Entry) bool { return lhs.row < rhs.row; @@ -64,7 +67,11 @@ pub fn load_entries(palette: *Type) !usize { }.less_fn; std.mem.sort(Entry, palette.entries.items, {}, less_fn); - return if (max_label_len > label.len + 3) 0 else label.len + 3 - max_label_len; + if (max_name_len > (palette.value.min_col_parent + palette.value.min_col_kind + palette.value.min_col_name)) { + return if (max_name_len > label.len + 3) 0 else label.len + 3 - max_name_len; + } else { + return 1 + palette.value.min_col_parent + palette.value.min_col_kind + if (palette.value.min_col_name > label.len + 3) 0 else palette.value.min_col_name + 3 - max_name_len; + } } pub fn clear_entries(palette: *Type) void { @@ -92,13 +99,18 @@ pub fn on_render_menu(palette: *Type, button: *Type.ButtonType, theme: *const Wi const label_, const container, const kind, _, _ = get_values(item_cbor); const icon_: []const u8 = kind_icon(@enumFromInt(kind)); const color: u24 = 0x0; - var buffer: [200]u8 = undefined; - const format_buffer = buffer[0..]; const this_kind_name = kind_name(@enumFromInt(kind)); - const formatted = fmt.bufPrint(format_buffer, "{s:<26} {s:<14} {s:<12}", .{ label_[0..@min(palette.value.min_col_name, label_.len)], container[0..@min(palette.value.min_col_parent, container.len)], this_kind_name[0..@min(palette.value.min_col_kind, this_kind_name.len)] }) catch ""; + var value: std.Io.Writer.Allocating = .init(palette.allocator); + defer value.deinit(); + const writer = &value.writer; + write_string(writer, label_[0..@min(palette.value.min_col_name, label_.len)], palette.value.min_col_name) catch {}; + write_padding(writer, 1, 2) catch {}; + write_string(writer, container[0..@min(palette.value.min_col_parent, container.len)], palette.value.min_col_parent) catch {}; + write_padding(writer, 1, 2) catch {}; + write_string(writer, this_kind_name[0..@min(palette.value.min_col_kind, this_kind_name.len)], palette.value.min_col_kind) catch {}; const indicator: []const u8 = &.{}; - return tui.render_file_item(&button.plane, formatted, icon_, color, indicator, matches_cbor, button.active, selected, button.hover, theme); + return tui.render_file_item(&button.plane, value.written(), icon_, color, indicator, matches_cbor, button.active, selected, button.hover, theme); } fn get_values(item_cbor: []const u8) struct { []const u8, []const u8, u8, usize, usize } { From c61bdd7042edc0a1c4e3726560e6e67452bf7ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20T=C3=A1mara?= Date: Mon, 17 Nov 2025 22:15:35 -0500 Subject: [PATCH 4/5] refactor: symbol palette column adjustments --- src/tui/mode/overlay/symbol_palette.zig | 103 +++++++++++++++++------- 1 file changed, 74 insertions(+), 29 deletions(-) diff --git a/src/tui/mode/overlay/symbol_palette.zig b/src/tui/mode/overlay/symbol_palette.zig index 47e8d74..3055bbd 100644 --- a/src/tui/mode/overlay/symbol_palette.zig +++ b/src/tui/mode/overlay/symbol_palette.zig @@ -20,6 +20,22 @@ pub const name = "Go to"; pub const description = "Symbols in scope"; pub const icon = "󱎸 "; +const Column = struct { + label: []const u8, + max_width: u8, + min_width: u8, +}; +const ColumnName = enum(u8) { + Name = 0, + Container = 1, + Kind = 2, +}; +const columns: [3]Column = .{ + .{ .label = "Name", .max_width = 26, .min_width = 4 }, + .{ .label = "Container", .max_width = 14, .min_width = 4 }, + .{ .label = "Kind", .max_width = 12, .min_width = 4 }, +}; + pub const Entry = struct { label: []const u8, row: usize, @@ -28,38 +44,74 @@ pub const Entry = struct { pub const ValueType = struct { start: ed.CurSel = .{}, - min_col_name: u8 = 26, - min_col_parent: u8 = 14, - min_col_kind: u8 = 12, + column_size: [3]u8 = undefined, }; pub const defaultValue: ValueType = .{}; +fn init_col_sizes(palette: *Type) void { + for (0..columns.len) |i| { + palette.value.column_size[i] = columns[i].min_width; + } +} + +fn update_min_col_sizes(palette: *Type) void { + for (0..columns.len) |i| { + palette.value.column_size[i] = @min(columns[i].max_width, palette.value.column_size[i]); + } +} + +fn update_max_col_sizes(palette: *Type, comp_sizes: []const usize) u8 { + var total_length: u8 = 0; + for (0..columns.len) |i| { + const truncated: u8 = @truncate(comp_sizes[i]); + palette.value.column_size[i] = @max(if (truncated > columns[i].max_width) columns[i].max_width else truncated, palette.value.column_size[i]); + total_length += palette.value.column_size[i]; + } + return total_length; +} + +fn write_columns(palette: *Type, writer: anytype, column_info: [][]const u8) void { + if (palette.value.column_size.len == 0) + return; + write_string(writer, column_info[0][0..@min(palette.value.column_size[0], column_info[0].len)], columns[0].max_width) catch {}; + + for (1..column_info.len) |i| { + write_padding(writer, 1, 2) catch {}; + write_string(writer, column_info[i][0..@min(palette.value.column_size[i], column_info[i].len)], columns[i].max_width) catch {}; + } +} + +fn total_row_width() u8 { + var total_width: u8 = 0; + + for (columns) |col| { + total_width += col.max_width; + } + return total_width; +} + pub fn load_entries(palette: *Type) !usize { const mv = tui.mainview() orelse return 0; const editor = tui.get_active_editor() orelse return error.NotFound; + var max_cols_len: u8 = 0; + var max_label_len: usize = 0; + palette.value.start = editor.get_primary().*; var iter: []const u8 = mv.symbols.items; + init_col_sizes(palette); while (iter.len > 0) { var cbor_item: []const u8 = undefined; if (!try cbor.matchValue(&iter, cbor.extract_cbor(&cbor_item))) return error.BadCompletion; - (try palette.entries.addOne(palette.allocator)).* = .{ .cbor = cbor_item, .label = undefined, .row = undefined }; - } + const label_, const parent_, const kind, const row, _ = get_values(cbor_item); + (try palette.entries.addOne(palette.allocator)).* = .{ .cbor = cbor_item, .label = label_[0..@min(columns[0].max_width, label_.len)], .row = row }; - var max_name_len: usize = 4; - var max_parent_len: usize = 4; - var max_kind_len: usize = 4; - for (palette.entries.items) |*item| { - const label_, const parent_, const kind, const row, _ = get_values(item.cbor); - item.label = label_; - item.row = row; - max_name_len = @max(max_name_len, item.label.len); - max_parent_len = @max(max_parent_len, parent_.len); - max_kind_len = @max(max_kind_len, kind_name(@enumFromInt(kind)).len); + const current_lengths: [3]usize = .{ label_.len, parent_.len, kind_name(@enumFromInt(kind)).len }; + const label_len: u8 = @truncate(if (label_.len > columns[0].max_width) columns[0].max_width else label_.len); + max_cols_len = @max(max_cols_len, label_len, update_max_col_sizes(palette, ¤t_lengths)); + max_label_len = @max(max_label_len, label_len); } + update_min_col_sizes(palette); - palette.value.min_col_name = @min(26, max_name_len); - palette.value.min_col_parent = @min(14, max_parent_len); - palette.value.min_col_kind = @min(12, max_kind_len); const less_fn = struct { fn less_fn(_: void, lhs: Entry, rhs: Entry) bool { return lhs.row < rhs.row; @@ -67,11 +119,8 @@ pub fn load_entries(palette: *Type) !usize { }.less_fn; std.mem.sort(Entry, palette.entries.items, {}, less_fn); - if (max_name_len > (palette.value.min_col_parent + palette.value.min_col_kind + palette.value.min_col_name)) { - return if (max_name_len > label.len + 3) 0 else label.len + 3 - max_name_len; - } else { - return 1 + palette.value.min_col_parent + palette.value.min_col_kind + if (palette.value.min_col_name > label.len + 3) 0 else palette.value.min_col_name + 3 - max_name_len; - } + const total_width = total_row_width(); + return 2 + if (max_cols_len > label.len + 3) total_width - max_label_len else label.len + 1 - max_cols_len; } pub fn clear_entries(palette: *Type) void { @@ -99,15 +148,11 @@ pub fn on_render_menu(palette: *Type, button: *Type.ButtonType, theme: *const Wi const label_, const container, const kind, _, _ = get_values(item_cbor); const icon_: []const u8 = kind_icon(@enumFromInt(kind)); const color: u24 = 0x0; - const this_kind_name = kind_name(@enumFromInt(kind)); var value: std.Io.Writer.Allocating = .init(palette.allocator); defer value.deinit(); const writer = &value.writer; - write_string(writer, label_[0..@min(palette.value.min_col_name, label_.len)], palette.value.min_col_name) catch {}; - write_padding(writer, 1, 2) catch {}; - write_string(writer, container[0..@min(palette.value.min_col_parent, container.len)], palette.value.min_col_parent) catch {}; - write_padding(writer, 1, 2) catch {}; - write_string(writer, this_kind_name[0..@min(palette.value.min_col_kind, this_kind_name.len)], palette.value.min_col_kind) catch {}; + var column_info = [_][]const u8{ label_, container, kind_name(@enumFromInt(kind)) }; + write_columns(palette, writer, &column_info); const indicator: []const u8 = &.{}; return tui.render_file_item(&button.plane, value.written(), icon_, color, indicator, matches_cbor, button.active, selected, button.hover, theme); From ad583879da1fc0d07d8be66f0c78ad0da8e5c22c Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 18 Nov 2025 15:56:52 +0100 Subject: [PATCH 5/5] feat: bind show_symbols to ctrl+shift+o in flow mode --- src/keybind/builtin/flow.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/keybind/builtin/flow.json b/src/keybind/builtin/flow.json index 0a0c8a3..5b6114d 100644 --- a/src/keybind/builtin/flow.json +++ b/src/keybind/builtin/flow.json @@ -225,6 +225,7 @@ ["shift+f11", "toggle_highlight_columns"], ["ctrl+f11", "toggle_inspector_view"], ["f12", "goto_definition"], + ["ctrl+shift+o", "show_symbols"], ["ctrl+space", "completion"], ["ctrl+.", "completion"], ["f34", "toggle_whitespace_mode"],