From 54aa30602fb0568e9f9bfa074ce65609387fad81 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Sun, 11 May 2025 18:59:16 -0500 Subject: [PATCH 01/12] added dG vim binding --- src/keybind/builtin/vim.json | 1 + src/tui/editor.zig | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index 21aa567..a1f647e 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -60,6 +60,7 @@ ["dw", "cut_word_right_vim"], ["db", "cut_word_left_vim"], ["dd", "cut_internal_vim"], + ["dG", "cut_buffer_end"], ["\"_dd", "delete_line"], ["cc", ["enter_mode", "insert"], ["cut_internal_vim"]], diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 48b13b1..51a492f 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -2961,6 +2961,15 @@ pub const Editor = struct { } pub const delete_word_left_meta: Meta = .{ .description = "Delete previous word" }; + pub fn cut_buffer_end(self: *Self, _: Context) Result { + const b = try self.buf_for_update(); + const text, const root = try self.cut_to(move_cursor_buffer_end, b.root); + self.set_clipboard_internal(text); + try self.update_buf(root); + self.clamp(); + } + pub const cut_buffer_end_meta: Meta = .{ .description = "Cut to the end of the buffer (copies cut text into clipboard)" }; + pub fn cut_word_left_vim(self: *Self, _: Context) Result { const b = try self.buf_for_update(); const text, const root = try self.cut_to(move_cursor_word_left_vim, b.root); From 43c77bb737a37fcaa53c6ac730b25627ecb8a56b Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Sun, 11 May 2025 20:38:26 -0500 Subject: [PATCH 02/12] added goto buffer begin/end keybinds for vim mode --- src/keybind/builtin/vim.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index a1f647e..fc4bd7f 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -121,6 +121,9 @@ ["h", "select_left"], ["l", "select_right"], + ["gg", "select_buffer_begin"], + ["G", "select_buffer_end"], + ["b", "select_word_left_vim"], ["w", "select_word_right_vim"], ["W", "select_word_right"], From 28fdd957479a669e80771485053670d7fac410a6 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Sun, 11 May 2025 20:44:09 -0500 Subject: [PATCH 03/12] added cut_buffer_begin command and vim binding --- src/keybind/builtin/vim.json | 1 + src/tui/editor.zig | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index fc4bd7f..9f7e2e0 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -61,6 +61,7 @@ ["db", "cut_word_left_vim"], ["dd", "cut_internal_vim"], ["dG", "cut_buffer_end"], + ["dgg", "cut_buffer_begin"], ["\"_dd", "delete_line"], ["cc", ["enter_mode", "insert"], ["cut_internal_vim"]], diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 51a492f..2509bad 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -2970,6 +2970,15 @@ pub const Editor = struct { } pub const cut_buffer_end_meta: Meta = .{ .description = "Cut to the end of the buffer (copies cut text into clipboard)" }; + pub fn cut_buffer_begin(self: *Self, _: Context) Result { + const b = try self.buf_for_update(); + const text, const root = try self.cut_to(move_cursor_buffer_begin, b.root); + self.set_clipboard_internal(text); + try self.update_buf(root); + self.clamp(); + } + pub const cut_buffer_begin_meta: Meta = .{ .description = "Cut to the beginning of the buffer (copies cut text into clipboard)" }; + pub fn cut_word_left_vim(self: *Self, _: Context) Result { const b = try self.buf_for_update(); const text, const root = try self.cut_to(move_cursor_word_left_vim, b.root); From da9507061676448e059cb81f6b71ea9108a43c6f Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Mon, 12 May 2025 09:02:56 -0500 Subject: [PATCH 04/12] added join line binding for vim --- src/keybind/builtin/vim.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index 9f7e2e0..8f208e3 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -26,6 +26,8 @@ ["h", "move_left_vim"], ["", "move_right_vim"], + ["J", "join_next_line"], + ["i", "enter_mode", "insert"], ["a", ["enter_mode", "insert"], ["move_right"]], ["I", ["enter_mode", "insert"], ["smart_move_begin"]], From d88b15ce040fd6edd04b986eafa5eff9907fe657 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Mon, 12 May 2025 09:39:51 -0500 Subject: [PATCH 05/12] began support vim mark system --- src/buffer/Buffer.zig | 7 +++++++ src/keybind/builtin/vim.json | 5 ++++- src/tui/editor.zig | 28 ++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/buffer/Buffer.zig b/src/buffer/Buffer.zig index 76ca303..e7859ce 100644 --- a/src/buffer/Buffer.zig +++ b/src/buffer/Buffer.zig @@ -27,6 +27,11 @@ pub const Metrics = struct { pub const egc_last_func = *const fn (self: Metrics, egcs: []const u8) []const u8; }; +pub const MarkLocation = struct { + row: usize, + col: usize, +}; + arena: std.heap.ArenaAllocator, allocator: Allocator, external_allocator: Allocator, @@ -54,6 +59,8 @@ file_type_name: ?[]const u8 = null, file_type_icon: ?[]const u8 = null, file_type_color: ?u24 = null, +marks: [256]?MarkLocation = .{null} ** 256, + pub const EolMode = enum { lf, crlf }; pub const EolModeTag = @typeInfo(EolMode).@"enum".tag_type; diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index 8f208e3..b72f392 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -106,7 +106,10 @@ ["6", "add_integer_argument_digit", 6], ["7", "add_integer_argument_digit", 7], ["8", "add_integer_argument_digit", 8], - ["9", "add_integer_argument_digit", 9] + ["9", "add_integer_argument_digit", 9], + + ["ma", "set_mark", 55], + ["'a", "goto_mark", 55] ] }, "visual": { diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 2509bad..db9ebf4 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -5130,6 +5130,34 @@ pub const Editor = struct { std.mem.sort(Diagnostic, self.diagnostics.items, {}, less_fn); } + pub fn goto_mark(self: *Self, ctx: Context) Result { + try self.send_editor_jump_source(); + var mark_id: u8 = 0; + if (!try ctx.args.match(.{tp.extract(&mark_id)})) + return error.InvalidGotoLineArgument; + const buf = self.buffer orelse return error.Stop; + const location = buf.marks[mark_id] orelse return error.UndefinedMark; + + const root = self.buf_root() catch return; + self.cancel_all_selections(); + const primary = self.get_primary(); + try primary.cursor.move_to(root, location.row, location.col, self.metrics); + self.clamp(); + try self.send_editor_jump_destination(); + } + pub const goto_mark_meta: Meta = .{ .arguments = &.{.integer} }; + + pub fn set_mark(self: *Self, ctx: Context) Result { + var mark_id: u8 = 0; + if (!try ctx.args.match(.{tp.extract(&mark_id)})) + return error.InvalidGotoLineArgument; + const primary = self.get_primary(); + const location: Buffer.MarkLocation = .{ .row = primary.cursor.row, .col = primary.cursor.col }; + var buf = self.buffer orelse return error.Stop; + buf.marks[mark_id] = location; + } + pub const set_mark_meta: Meta = .{ .arguments = &.{.integer} }; + pub fn goto_line(self: *Self, ctx: Context) Result { try self.send_editor_jump_source(); var line: usize = 0; From 2d583fbd9e5b5d03aab59d377fba7a0dd99e99b5 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Mon, 12 May 2025 09:47:28 -0500 Subject: [PATCH 06/12] add bindings for the rest of the mark manipulation commands --- src/keybind/builtin/vim.json | 55 ++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index b72f392..dc50ac7 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -108,8 +108,59 @@ ["8", "add_integer_argument_digit", 8], ["9", "add_integer_argument_digit", 9], - ["ma", "set_mark", 55], - ["'a", "goto_mark", 55] + ["ma", "set_mark", 97], + ["mb", "set_mark", 98], + ["mc", "set_mark", 99], + ["md", "set_mark", 100], + ["me", "set_mark", 101], + ["mf", "set_mark", 102], + ["mg", "set_mark", 103], + ["mh", "set_mark", 104], + ["mi", "set_mark", 105], + ["mj", "set_mark", 106], + ["mk", "set_mark", 107], + ["ml", "set_mark", 108], + ["mm", "set_mark", 109], + ["mn", "set_mark", 110], + ["mo", "set_mark", 111], + ["mp", "set_mark", 112], + ["mq", "set_mark", 113], + ["mr", "set_mark", 114], + ["ms", "set_mark", 115], + ["mt", "set_mark", 116], + ["mu", "set_mark", 117], + ["mv", "set_mark", 118], + ["mw", "set_mark", 119], + ["mx", "set_mark", 120], + ["my", "set_mark", 121], + ["mz", "set_mark", 122], + + ["'a", "goto_mark", 97], + ["'b", "goto_mark", 98], + ["'c", "goto_mark", 99], + ["'d", "goto_mark", 100], + ["'e", "goto_mark", 101], + ["'f", "goto_mark", 102], + ["'g", "goto_mark", 103], + ["'h", "goto_mark", 104], + ["'i", "goto_mark", 105], + ["'j", "goto_mark", 106], + ["'k", "goto_mark", 107], + ["'l", "goto_mark", 108], + ["'m", "goto_mark", 109], + ["'n", "goto_mark", 110], + ["'o", "goto_mark", 111], + ["'p", "goto_mark", 112], + ["'q", "goto_mark", 113], + ["'r", "goto_mark", 114], + ["'s", "goto_mark", 115], + ["'t", "goto_mark", 116], + ["'u", "goto_mark", 117], + ["'v", "goto_mark", 118], + ["'w", "goto_mark", 119], + ["'x", "goto_mark", 120], + ["'y", "goto_mark", 121], + ["'z", "goto_mark", 122] ] }, "visual": { From 4765f47dd0e029e9cba3c7b9071585ac81a3d064 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Mon, 12 May 2025 11:38:41 -0500 Subject: [PATCH 07/12] begin supporting global marks --- src/tui/editor.zig | 24 ++++++++++++++++++++++++ src/tui/tui.zig | 11 +++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index db9ebf4..96ffb0c 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -5130,6 +5130,30 @@ pub const Editor = struct { std.mem.sort(Diagnostic, self.diagnostics.items, {}, less_fn); } + pub fn goto_global_mark(self: *Self, ctx: Context) Result { + try self.send_editor_jump_source(); + var mark_id: u8 = 0; + if (!try ctx.args.match(.{tp.extract(&mark_id)})) + return error.InvalidGotoLineArgument; + const location = tui.get_global_marks()[mark_id] orelse return error.UndefinedGlobalMark; + _ = location; + + //TODO: figure out how to goto location in another file + } + pub const goto_global_mark_meta: Meta = .{ .arguments = &.{.integer} }; + + pub fn set_global_mark(self: *Self, ctx: Context) Result { + var mark_id: u8 = 0; + if (!try ctx.args.match(.{tp.extract(&mark_id)})) + return error.InvalidGotoLineArgument; + const primary = self.get_primary(); + const buf = self.buffer orelse return error.Stop; + var location: tui.GlobalMarkLocation = .{ .row = primary.cursor.row, .col = primary.cursor.col }; + std.mem.copyForwards(u8, &location.filepath, buf.file_path); + tui.get_global_marks()[mark_id] = location; + } + pub const set_global_mark_meta: Meta = .{ .arguments = &.{.integer} }; + pub fn goto_mark(self: *Self, ctx: Context) Result { try self.send_editor_jump_source(); var mark_id: u8 = 0; diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 7998654..cc6ecad 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -20,6 +20,12 @@ const MainView = @import("mainview.zig"); const Allocator = std.mem.Allocator; +pub const GlobalMarkLocation = struct { + row: usize, + col: usize, + filepath: [512]u8 = .{0} ** 512, +}; + allocator: Allocator, rdr_: renderer, config_: @import("config"), @@ -62,6 +68,7 @@ fontfaces_: std.ArrayListUnmanaged([]const u8) = .{}, enable_mouse_idle_timer: bool = false, query_cache_: *syntax.QueryCache, frames_rendered_: usize = 0, +global_marks: [256]?GlobalMarkLocation = .{null} ** 256, const keepalive = std.time.us_per_day * 365; // one year const idle_frames = 0; @@ -1091,6 +1098,10 @@ fn current() *Self { return instance_ orelse @panic("tui call out of context"); } +pub fn get_global_marks() *[256]?GlobalMarkLocation { + return ¤t().global_marks; +} + pub fn rdr() *renderer { return ¤t().rdr_; } From 7c51fa840034ca3b23e73839f430f85dfd2dbda5 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Mon, 12 May 2025 11:46:05 -0500 Subject: [PATCH 08/12] add vim bindings for setting and goto'ing global marks --- src/keybind/builtin/vim.json | 56 +++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index dc50ac7..dc77afd 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -160,7 +160,61 @@ ["'w", "goto_mark", 119], ["'x", "goto_mark", 120], ["'y", "goto_mark", 121], - ["'z", "goto_mark", 122] + ["'z", "goto_mark", 122], + + ["mA", "set_global_mark", 65], + ["mB", "set_global_mark", 66], + ["mC", "set_global_mark", 67], + ["mD", "set_global_mark", 68], + ["mE", "set_global_mark", 69], + ["mF", "set_global_mark", 70], + ["mG", "set_global_mark", 71], + ["mH", "set_global_mark", 72], + ["mI", "set_global_mark", 73], + ["mJ", "set_global_mark", 74], + ["mK", "set_global_mark", 75], + ["mL", "set_global_mark", 76], + ["mM", "set_global_mark", 77], + ["mN", "set_global_mark", 78], + ["mO", "set_global_mark", 79], + ["mP", "set_global_mark", 80], + ["mQ", "set_global_mark", 81], + ["mR", "set_global_mark", 82], + ["mS", "set_global_mark", 83], + ["mT", "set_global_mark", 84], + ["mU", "set_global_mark", 85], + ["mV", "set_global_mark", 86], + ["mW", "set_global_mark", 87], + ["mX", "set_global_mark", 88], + ["mY", "set_global_mark", 89], + ["mZ", "set_global_mark", 90] + + ["'A", "goto_global_mark", 65], + ["'B", "goto_global_mark", 66], + ["'C", "goto_global_mark", 67], + ["'D", "goto_global_mark", 68], + ["'E", "goto_global_mark", 69], + ["'F", "goto_global_mark", 70], + ["'G", "goto_global_mark", 71], + ["'H", "goto_global_mark", 72], + ["'I", "goto_global_mark", 73], + ["'J", "goto_global_mark", 74], + ["'K", "goto_global_mark", 75], + ["'L", "goto_global_mark", 76], + ["'M", "goto_global_mark", 77], + ["'N", "goto_global_mark", 78], + ["'O", "goto_global_mark", 79], + ["'P", "goto_global_mark", 80], + ["'Q", "goto_global_mark", 81], + ["'R", "goto_global_mark", 82], + ["'S", "goto_global_mark", 83], + ["'T", "goto_global_mark", 84], + ["'U", "goto_global_mark", 85], + ["'V", "goto_global_mark", 86], + ["'W", "goto_global_mark", 87], + ["'X", "goto_global_mark", 88], + ["'Y", "goto_global_mark", 89], + ["'Z", "goto_global_mark", 90] ] }, "visual": { From acded15af821d2e78c153da6b12f86f194ca69c5 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Mon, 12 May 2025 12:26:36 -0500 Subject: [PATCH 09/12] added * command in vim mode --- src/keybind/builtin/vim.json | 3 ++- src/tui/editor.zig | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index dc77afd..6d35d71 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -86,6 +86,7 @@ ["", "redo"], ["/", "find"], + ["*", "find_word_at_cursor"], ["", "TODO"], @@ -187,7 +188,7 @@ ["mW", "set_global_mark", 87], ["mX", "set_global_mark", 88], ["mY", "set_global_mark", 89], - ["mZ", "set_global_mark", 90] + ["mZ", "set_global_mark", 90], ["'A", "goto_global_mark", 65], ["'B", "goto_global_mark", 66], diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 96ffb0c..bab36ef 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -4772,6 +4772,14 @@ pub const Editor = struct { } pub const find_query_meta: Meta = .{ .arguments = &.{.string} }; + pub fn find_word_at_cursor(self: *Self, ctx: Context) Result { + _ = ctx; + const query: []const u8 = try self.copy_word_at_cursor(self.allocator); + try self.find_in_buffer(query); + self.allocator.free(query); + } + pub const find_word_at_cursor_meta: Meta = .{ .description = "Search for the word under the cursor" }; + fn find_in(self: *Self, query: []const u8, comptime find_f: ripgrep.FindF, write_buffer: bool) !void { const root = try self.buf_root(); self.cancel_all_matches(); From fcbb377237430ac9d46d9701384544b50fe44a89 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Tue, 13 May 2025 06:48:38 -0500 Subject: [PATCH 10/12] removed mark related code --- src/buffer/Buffer.zig | 7 -- src/keybind/builtin/vim.json | 138 +++++++---------------------------- src/tui/editor.zig | 52 ------------- src/tui/tui.zig | 7 -- 4 files changed, 25 insertions(+), 179 deletions(-) diff --git a/src/buffer/Buffer.zig b/src/buffer/Buffer.zig index e7859ce..76ca303 100644 --- a/src/buffer/Buffer.zig +++ b/src/buffer/Buffer.zig @@ -27,11 +27,6 @@ pub const Metrics = struct { pub const egc_last_func = *const fn (self: Metrics, egcs: []const u8) []const u8; }; -pub const MarkLocation = struct { - row: usize, - col: usize, -}; - arena: std.heap.ArenaAllocator, allocator: Allocator, external_allocator: Allocator, @@ -59,8 +54,6 @@ file_type_name: ?[]const u8 = null, file_type_icon: ?[]const u8 = null, file_type_color: ?u24 = null, -marks: [256]?MarkLocation = .{null} ** 256, - pub const EolMode = enum { lf, crlf }; pub const EolModeTag = @typeInfo(EolMode).@"enum".tag_type; diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index 6d35d71..d76c010 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -107,115 +107,7 @@ ["6", "add_integer_argument_digit", 6], ["7", "add_integer_argument_digit", 7], ["8", "add_integer_argument_digit", 8], - ["9", "add_integer_argument_digit", 9], - - ["ma", "set_mark", 97], - ["mb", "set_mark", 98], - ["mc", "set_mark", 99], - ["md", "set_mark", 100], - ["me", "set_mark", 101], - ["mf", "set_mark", 102], - ["mg", "set_mark", 103], - ["mh", "set_mark", 104], - ["mi", "set_mark", 105], - ["mj", "set_mark", 106], - ["mk", "set_mark", 107], - ["ml", "set_mark", 108], - ["mm", "set_mark", 109], - ["mn", "set_mark", 110], - ["mo", "set_mark", 111], - ["mp", "set_mark", 112], - ["mq", "set_mark", 113], - ["mr", "set_mark", 114], - ["ms", "set_mark", 115], - ["mt", "set_mark", 116], - ["mu", "set_mark", 117], - ["mv", "set_mark", 118], - ["mw", "set_mark", 119], - ["mx", "set_mark", 120], - ["my", "set_mark", 121], - ["mz", "set_mark", 122], - - ["'a", "goto_mark", 97], - ["'b", "goto_mark", 98], - ["'c", "goto_mark", 99], - ["'d", "goto_mark", 100], - ["'e", "goto_mark", 101], - ["'f", "goto_mark", 102], - ["'g", "goto_mark", 103], - ["'h", "goto_mark", 104], - ["'i", "goto_mark", 105], - ["'j", "goto_mark", 106], - ["'k", "goto_mark", 107], - ["'l", "goto_mark", 108], - ["'m", "goto_mark", 109], - ["'n", "goto_mark", 110], - ["'o", "goto_mark", 111], - ["'p", "goto_mark", 112], - ["'q", "goto_mark", 113], - ["'r", "goto_mark", 114], - ["'s", "goto_mark", 115], - ["'t", "goto_mark", 116], - ["'u", "goto_mark", 117], - ["'v", "goto_mark", 118], - ["'w", "goto_mark", 119], - ["'x", "goto_mark", 120], - ["'y", "goto_mark", 121], - ["'z", "goto_mark", 122], - - ["mA", "set_global_mark", 65], - ["mB", "set_global_mark", 66], - ["mC", "set_global_mark", 67], - ["mD", "set_global_mark", 68], - ["mE", "set_global_mark", 69], - ["mF", "set_global_mark", 70], - ["mG", "set_global_mark", 71], - ["mH", "set_global_mark", 72], - ["mI", "set_global_mark", 73], - ["mJ", "set_global_mark", 74], - ["mK", "set_global_mark", 75], - ["mL", "set_global_mark", 76], - ["mM", "set_global_mark", 77], - ["mN", "set_global_mark", 78], - ["mO", "set_global_mark", 79], - ["mP", "set_global_mark", 80], - ["mQ", "set_global_mark", 81], - ["mR", "set_global_mark", 82], - ["mS", "set_global_mark", 83], - ["mT", "set_global_mark", 84], - ["mU", "set_global_mark", 85], - ["mV", "set_global_mark", 86], - ["mW", "set_global_mark", 87], - ["mX", "set_global_mark", 88], - ["mY", "set_global_mark", 89], - ["mZ", "set_global_mark", 90], - - ["'A", "goto_global_mark", 65], - ["'B", "goto_global_mark", 66], - ["'C", "goto_global_mark", 67], - ["'D", "goto_global_mark", 68], - ["'E", "goto_global_mark", 69], - ["'F", "goto_global_mark", 70], - ["'G", "goto_global_mark", 71], - ["'H", "goto_global_mark", 72], - ["'I", "goto_global_mark", 73], - ["'J", "goto_global_mark", 74], - ["'K", "goto_global_mark", 75], - ["'L", "goto_global_mark", 76], - ["'M", "goto_global_mark", 77], - ["'N", "goto_global_mark", 78], - ["'O", "goto_global_mark", 79], - ["'P", "goto_global_mark", 80], - ["'Q", "goto_global_mark", 81], - ["'R", "goto_global_mark", 82], - ["'S", "goto_global_mark", 83], - ["'T", "goto_global_mark", 84], - ["'U", "goto_global_mark", 85], - ["'V", "goto_global_mark", 86], - ["'W", "goto_global_mark", 87], - ["'X", "goto_global_mark", 88], - ["'Y", "goto_global_mark", 89], - ["'Z", "goto_global_mark", 90] + ["9", "add_integer_argument_digit", 9] ] }, "visual": { @@ -242,7 +134,6 @@ ["B", "select_word_left"], ["e", "select_word_right_end_vim"], - ["0", "move_begin"], ["^", "smart_move_begin"], ["$", "select_end"], [":", "open_command_palette"], @@ -270,7 +161,18 @@ ["c", ["enter_mode", "insert"], ["cut_forward_internal"]], ["C", ["enter_mode", "insert"], ["cut_to_end_vim"]], - ["D", "cut_to_end_vim"] + ["D", "cut_to_end_vim"], + + ["0", "move_begin_or_add_integer_argument_zero"], + ["1", "add_integer_argument_digit", 1], + ["2", "add_integer_argument_digit", 2], + ["3", "add_integer_argument_digit", 3], + ["4", "add_integer_argument_digit", 4], + ["5", "add_integer_argument_digit", 5], + ["6", "add_integer_argument_digit", 6], + ["7", "add_integer_argument_digit", 7], + ["8", "add_integer_argument_digit", 8], + ["9", "add_integer_argument_digit", 9] ] }, "visual line": { @@ -285,7 +187,6 @@ ["k", "select_up"], ["j", "select_down"], - ["0", "move_begin"], ["^", "smart_move_begin"], ["$", "move_end"], [":", "open_command_palette"], @@ -307,7 +208,18 @@ ["c", ["enter_mode", "insert"], ["cut_internal_vim"]], ["C", ["enter_mode", "insert"], ["cut_to_end_vim"]], - ["D", "cut_to_end_vim"] + ["D", "cut_to_end_vim"], + + ["0", "move_begin_or_add_integer_argument_zero"], + ["1", "add_integer_argument_digit", 1], + ["2", "add_integer_argument_digit", 2], + ["3", "add_integer_argument_digit", 3], + ["4", "add_integer_argument_digit", 4], + ["5", "add_integer_argument_digit", 5], + ["6", "add_integer_argument_digit", 6], + ["7", "add_integer_argument_digit", 7], + ["8", "add_integer_argument_digit", 8], + ["9", "add_integer_argument_digit", 9] ] }, "insert": { diff --git a/src/tui/editor.zig b/src/tui/editor.zig index bab36ef..f036316 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -5138,58 +5138,6 @@ pub const Editor = struct { std.mem.sort(Diagnostic, self.diagnostics.items, {}, less_fn); } - pub fn goto_global_mark(self: *Self, ctx: Context) Result { - try self.send_editor_jump_source(); - var mark_id: u8 = 0; - if (!try ctx.args.match(.{tp.extract(&mark_id)})) - return error.InvalidGotoLineArgument; - const location = tui.get_global_marks()[mark_id] orelse return error.UndefinedGlobalMark; - _ = location; - - //TODO: figure out how to goto location in another file - } - pub const goto_global_mark_meta: Meta = .{ .arguments = &.{.integer} }; - - pub fn set_global_mark(self: *Self, ctx: Context) Result { - var mark_id: u8 = 0; - if (!try ctx.args.match(.{tp.extract(&mark_id)})) - return error.InvalidGotoLineArgument; - const primary = self.get_primary(); - const buf = self.buffer orelse return error.Stop; - var location: tui.GlobalMarkLocation = .{ .row = primary.cursor.row, .col = primary.cursor.col }; - std.mem.copyForwards(u8, &location.filepath, buf.file_path); - tui.get_global_marks()[mark_id] = location; - } - pub const set_global_mark_meta: Meta = .{ .arguments = &.{.integer} }; - - pub fn goto_mark(self: *Self, ctx: Context) Result { - try self.send_editor_jump_source(); - var mark_id: u8 = 0; - if (!try ctx.args.match(.{tp.extract(&mark_id)})) - return error.InvalidGotoLineArgument; - const buf = self.buffer orelse return error.Stop; - const location = buf.marks[mark_id] orelse return error.UndefinedMark; - - const root = self.buf_root() catch return; - self.cancel_all_selections(); - const primary = self.get_primary(); - try primary.cursor.move_to(root, location.row, location.col, self.metrics); - self.clamp(); - try self.send_editor_jump_destination(); - } - pub const goto_mark_meta: Meta = .{ .arguments = &.{.integer} }; - - pub fn set_mark(self: *Self, ctx: Context) Result { - var mark_id: u8 = 0; - if (!try ctx.args.match(.{tp.extract(&mark_id)})) - return error.InvalidGotoLineArgument; - const primary = self.get_primary(); - const location: Buffer.MarkLocation = .{ .row = primary.cursor.row, .col = primary.cursor.col }; - var buf = self.buffer orelse return error.Stop; - buf.marks[mark_id] = location; - } - pub const set_mark_meta: Meta = .{ .arguments = &.{.integer} }; - pub fn goto_line(self: *Self, ctx: Context) Result { try self.send_editor_jump_source(); var line: usize = 0; diff --git a/src/tui/tui.zig b/src/tui/tui.zig index cc6ecad..57d72b1 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -20,12 +20,6 @@ const MainView = @import("mainview.zig"); const Allocator = std.mem.Allocator; -pub const GlobalMarkLocation = struct { - row: usize, - col: usize, - filepath: [512]u8 = .{0} ** 512, -}; - allocator: Allocator, rdr_: renderer, config_: @import("config"), @@ -68,7 +62,6 @@ fontfaces_: std.ArrayListUnmanaged([]const u8) = .{}, enable_mouse_idle_timer: bool = false, query_cache_: *syntax.QueryCache, frames_rendered_: usize = 0, -global_marks: [256]?GlobalMarkLocation = .{null} ** 256, const keepalive = std.time.us_per_day * 365; // one year const idle_frames = 0; From 7ec25cfb46b4598ff5f4cb162a1010bee8c0b651 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Tue, 13 May 2025 06:51:15 -0500 Subject: [PATCH 11/12] fix compile error --- src/tui/tui.zig | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 57d72b1..7998654 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -1091,10 +1091,6 @@ fn current() *Self { return instance_ orelse @panic("tui call out of context"); } -pub fn get_global_marks() *[256]?GlobalMarkLocation { - return ¤t().global_marks; -} - pub fn rdr() *renderer { return ¤t().rdr_; } From 0e182b6ae44bef82c01d59b7560e61d389339348 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Tue, 13 May 2025 08:40:30 -0500 Subject: [PATCH 12/12] add vim bindings for swapping tabs --- src/keybind/builtin/vim.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index d76c010..3b00be5 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -98,6 +98,9 @@ ["", ["move_down"], ["move_begin"]], ["", ["move_down"], ["move_begin"]], + ["gt", "next_tab"], + ["gT", "previous_tab"], + ["0", "move_begin_or_add_integer_argument_zero"], ["1", "add_integer_argument_digit", 1], ["2", "add_integer_argument_digit", 2],